Documentation
¶
Index ¶
Constants ¶
View Source
const (
HeaderAPIKey = "X-modprox-api-key"
)
Variables ¶
This section is empty.
Functions ¶
func Chain ¶
func Chain(h http.Handler, m ...Middleware) http.Handler
Chain recursively chains middleware together.
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, i interface{})
Write the given struct as JSON into w.
Types ¶
type Middleware ¶
A Middleware is used to execute intermediate Handlers in response to a request.
func KeyGuard ¶
func KeyGuard(keys []string) Middleware
KeyGuard creates a Middleware which protects access to a handler by first checking for the X-modprox-api-key header being set. If at least one of the values for the header matches one of the keys configured for the KeyGuard, the handler is executed for the request. Otherwise, a StatusForbidden response is returned.
Click to show internal directories.
Click to hide internal directories.