Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Disable authentication entirely, allowing all requests NoAuth = false )
Functions ¶
func Auth ¶
func Auth(repo database.TokenRepository, next http.HandlerFunc) http.HandlerFunc
Auth checks the token in the Authorization header against the provided database. The token is then provided in the context value If `NoAuth` is false - all checks are skipped and the dummy token is set in the context
func Error ¶
func Error(handler ErrorHandler) http.HandlerFunc
Error wraps the custom handler, which is an extension of http.HandlerFunc, that can return an error. When the error is not nil, Error encodes it into a standard json form, as follows:
{ "error": true, "message": "..." }
func Json ¶
func Json(next http.HandlerFunc) http.HandlerFunc
Json sets the "Content-Type" header of the response to "application/json; charset=utf-8"
Types ¶
type ErrorHandler ¶
type ErrorHandler func(http.ResponseWriter, *http.Request) error
ErrorHandler is similar to http.HandlerFunc, but it can also return an error
type ServerError ¶
Click to show internal directories.
Click to hide internal directories.