Documentation ¶
Overview ¶
Package http includes handlers and utilties
Index ¶
- func BasicAuthMiddleware(next http.Handler, username, password, realm string) http.HandlerFunc
- func CORSMiddleware(next http.Handler, origin string) http.HandlerFunc
- func GetTraceID(ctx context.Context) string
- func ReadAllAndReplaceBody(r *http.Request) ([]byte, error)
- func TraceLoggingMiddleware(next http.Handler, logger log.Logger, traceID func(*http.Request) string) http.HandlerFunc
- func VersionHandler(version string) http.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuthMiddleware ¶
func BasicAuthMiddleware(next http.Handler, username, password, realm string) http.HandlerFunc
BasicAuthMiddleware is a simple HTTP plain authentication middleware.
func CORSMiddleware ¶ added in v0.1.1
func CORSMiddleware(next http.Handler, origin string) http.HandlerFunc
CORSMiddleware adds "Access-Control-Allow-" headers to the response. Optionally specify an origin.
func GetTraceID ¶ added in v0.4.0
func ReadAllAndReplaceBody ¶
ReadAllAndReplaceBody reads all of r.Body and replaces it with a new byte buffer.
func TraceLoggingMiddleware ¶
func TraceLoggingMiddleware(next http.Handler, logger log.Logger, traceID func(*http.Request) string) http.HandlerFunc
TraceLoggingMiddleware sets up a trace ID in the request context and logs HTTP requests.
func VersionHandler ¶
func VersionHandler(version string) http.HandlerFunc
VersionHandler returns a simple JSON response from a version string.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.