exhttp

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: MPL-2.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCORSHeaders

func AddCORSHeaders(w http.ResponseWriter)

func CORSMiddleware

func CORSMiddleware(next http.Handler) http.Handler

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 ErrorBodyGenerators struct {
	NotFound         func() []byte
	MethodNotAllowed func() []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL