Documentation
¶
Index ¶
- func AddCORSHeaders(w http.ResponseWriter)
- func ApplyMiddleware(router http.Handler, middlewares ...Middleware) http.Handler
- func CORSMiddleware(next http.Handler) http.Handler
- func HandleErrors(next http.Handler, gen ErrorBodyGenerators) http.Handler
- func WriteEmptyJSONResponse(w http.ResponseWriter, httpStatusCode int)
- func WriteJSONData(w http.ResponseWriter, httpStatusCode int, data []byte)
- func WriteJSONResponse(w http.ResponseWriter, httpStatusCode int, jsonData any)
- type ErrorBodyGenerators
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCORSHeaders ¶
func AddCORSHeaders(w http.ResponseWriter)
func ApplyMiddleware ¶
func ApplyMiddleware(router http.Handler, middlewares ...Middleware) http.Handler
ApplyMiddleware applies the provided Middleware functions to the given router. The middlewares will be applied in the order they are provided.
func CORSMiddleware ¶
CORSMiddleware adds CORS headers to the response and handles OPTIONS requests by returning 200 OK immediately.
func HandleErrors ¶
func HandleErrors(next http.Handler, gen ErrorBodyGenerators) http.Handler
func WriteEmptyJSONResponse ¶
func WriteEmptyJSONResponse(w http.ResponseWriter, httpStatusCode int)
func WriteJSONData ¶
func WriteJSONData(w http.ResponseWriter, httpStatusCode int, data []byte)
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, httpStatusCode int, jsonData any)
Types ¶
type ErrorBodyGenerators ¶
type Middleware ¶
Middleware represents a middleware that can be applied to an http.Handler.
func StripPrefix ¶
func StripPrefix(prefix string) Middleware
StripPrefix is a wrapper for http.StripPrefix is compatible with the middleware pattern.
Click to show internal directories.
Click to hide internal directories.