Documentation ¶
Overview ¶
Package middleware contains middlewares for logging, auth, custom errors and so on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth( realm string, authHeader string, credentialsFile string, ) func(next http.Handler) http.Handler
Auth middleware which uses Firebase auth tokens and puts userID into ctx for handlers to decide what can be accessed by given user
func Base ¶
Base middleware which - loggs information about request and response - catches panic and logs out the debug.Stack - prepares requestID (from specified header or generates new one)
func Error ¶
Error allows overriding net/http error responses with your own..
You might want to use one for rest api with text/plain content and otherone for stuff vidible by user with text/html content type.
Here is an example usage:
contentType := "text/plain; charset=utf-8" customErrors := make(map[int][]byte) customErrors[http.StatusNotFound] = []byte("custom 404..") ... errorMiddleware := middleware.Error(contentType, customErrors) server := &http.Server{ Addr: ":XXXX", Handler: errorMiddleware(router), } server.ListenAndServe()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.