// NewHandlerWrapper returns a handler that first performs bearer token authorization and, if authorized,
// invokes the wrapped handler.
NewHandlerWrapper returns a handler that first performs bearer token authorization and, if authorized,
invokes the wrapped handler.
// NewHandlerWrapper returns a handler that first performs bearer token authorization and if authorized // invokes the wrapped handler .
func NewHandlerWrapper(handler common.HTTPHandler, tm tokenManager) *HandlerWrapper {
	return &HandlerWrapper{
		verifier:      NewTokenVerifier(tm, handler.Path(), handler.Method()),
		HTTPHandler:   handler,
		handler:       handler,
		handleRequest: handler.Handler(),
		writeResponse: func(w http.ResponseWriter, status int, body []byte) {
			w.WriteHeader(status)
			if len(body) > 0 {
				if _, err := w.Write(body); err != nil {
					logger.Warnf("[%s] Unable to write response: %s", handler.Path(), err)
					return
				}
				logger.Debugf("[%s] Wrote response: %s", handler.Path(), body)
			}
		},
	}
}
func NewHandlerWrapper ( handler common . HTTPHandler , tm tokenManager ) * HandlerWrapper { return & HandlerWrapper { verifier : NewTokenVerifier ( tm , handler . Path ( ) , handler . Method ( ) ) , HTTPHandler : handler , handler : handler , handleRequest : handler . Handler ( ) , writeResponse : func ( w http . ResponseWriter , status int , body [ ] byte ) { w . WriteHeader ( status ) if len ( body ) > 0 { if _ , err := w . Write ( body ) ; err != nil { logger . Warnf ( " " , handler . Path ( ) , err ) return } logger . Debugf ( " " , handler . Path ( ) , body ) } } , } }
NewHandlerWrapper returns a handler that first performs bearer token authorization and, if authorized,
invokes the wrapped handler.
NewHandlerWrapper returns a handler that first performs bearer token authorization and if authorized invokes the wrapped handler .