package exhttp
import "go.mau.fi/util/exhttp"
Index ¶
- func AddCORSHeaders(w http.ResponseWriter)
- 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
Functions ¶
func AddCORSHeaders ¶
func AddCORSHeaders(w http.ResponseWriter)
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 ¶
Source Files ¶
cors.go handleerrors.go json.go
- Version
- v0.8.0
- Published
- Sep 16, 2024
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 1 day ago –
Tools for package owners.