Documentation
¶
Overview ¶
HTTP utils for basic authentication etc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicAuthHandler ¶
type BasicAuthHandler struct {
Username string
Password string
Realm string
OriginalHandler http.Handler
}
Wraps an original http.Handler with credentials to do http basic authentication and a realm text to be displayed in 401 responses.
Usage:
authHandler := httpUtil.BasicAuthHandler{
Username: "user123",
Password: "secret",
Realm: "Please provide username and password",
OriginalHandler: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
// ..
}),
}
http.Handle("/sample", authHandler)
func (BasicAuthHandler) ServeHTTP ¶
func (h BasicAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
BasicAuthHandler satisfies http.Handler interface and after checking the credentials delegates to the original handler.
Click to show internal directories.
Click to hide internal directories.