Documentation
¶
Index ¶
- func BasicAuth(h httprouter.Handle, requiredUser, requiredPassword string) httprouter.Handle
- func BearerAuth(h httprouter.Handle, signingSecret string) httprouter.Handle
- func Cors(h httprouter.Handle) httprouter.Handle
- func HandleError(h Handler) httprouter.Handle
- func Log(h httprouter.Handle) httprouter.Handle
- type ContextKey
- type Error
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
func BasicAuth(h httprouter.Handle, requiredUser, requiredPassword string) httprouter.Handle
BasicAuth handles basic authentication. It checkes if the the sent basic auth crendentials matchs the required user and password.
func BearerAuth ¶
func BearerAuth(h httprouter.Handle, signingSecret string) httprouter.Handle
BearerAuth handles bearer token authentication. The claims from the JWT token can be accessed in the handler function as follows:
claims, ok := r.Context() .Value(middleware.ContextJWTKey) .(middleware.MapClaims)
func HandleError ¶
func HandleError(h Handler) httprouter.Handle
HandleError display the error message to the user with the correct HTTP status code and log the full error to the developer console.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey implements type for context key.
const ContextJWTKey ContextKey = "jwt"
ContextJWTKey is the key for the jwt context value.
type Error ¶
Error is our custom error type. See: http://blog.golang.org/error-handling-and-go
type Handler ¶
type Handler func(http.ResponseWriter, *http.Request, httprouter.Params) *Error
Handler is our custom HTTP handler. See: http://blog.golang.org/error-handling-and-go