// AuthorizerHook is a middleware hook that populates the context's Claims object
// with data from the request's authorization token. If there is no authorization
// token, or the token is invalid, it returns an error.
//
// This hook effectively acts as a requirement that the authorization token is correct.
AuthorizerHook is a middleware hook that populates the context's Claims object
with data from the request's authorization token. If there is no authorization
token, or the token is invalid, it returns an error.

This hook effectively acts as a requirement that the authorization token is correct.
// AuthorizerHook is a middleware hook that populates the context ' s Claims object // with data from the request ' s authorization token . If there is no authorization // token or the token is invalid it returns an error . // // This hook effectively acts as a requirement that the authorization token is correct .
func AuthorizerHook(token *TokenSigner) dispatch.MiddlewareHook {
	return func(input *dispatch.EndpointInput) (*dispatch.EndpointInput, error) {
		if input == nil {
			return nil, errors.New("Missing authorization token")
		}
		authToken, err := input.Ctx.Request.Cookie("dispatch-auth")
		if authToken == nil || authToken.Value == "" {
			return nil, errors.New("Missing authorization token")
		}
		if err != nil {
			return nil, err
		}
		claims, err := token.ParseToken(authToken.Value)
		if err != nil {
			return nil, errors.New("Invalid authorization token")
		}
		input.Ctx.Claims = claims
		return input, nil
	}
}
func AuthorizerHook ( token * TokenSigner ) dispatch . MiddlewareHook { return func ( input * dispatch . EndpointInput ) ( * dispatch . EndpointInput , error ) { if input == nil { return nil , errors . New ( " " ) } authToken , err := input . Ctx . Request . Cookie ( " " ) if authToken == nil || authToken . Value == " " { return nil , errors . New ( " " ) } if err != nil { return nil , err } claims , err := token . ParseToken ( authToken . Value ) if err != nil { return nil , errors . New ( " " ) } input . Ctx . Claims = claims return input , nil } }
AuthorizerHook is a middleware hook that populates the context's Claims object
with data from the request's authorization token.
AuthorizerHook is a middleware hook that populates the context ' s Claims object with data from the request ' s authorization token .
// Check for authorization header