middleware

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapt

func Adapt(h http.HandlerFunc, adapters ...Adapter) http.HandlerFunc

Adapt Iterate over adapters and run them one by one

func ResponseWithCustomCode

func ResponseWithCustomCode(w http.ResponseWriter, code int, payload interface{})

ResponseWithJson returns formed JSON

func ResponseWithJson

func ResponseWithJson(w http.ResponseWriter, payload interface{})

ResponseWithJson returns formed JSON

Types

type Adapter

type Adapter func(http.HandlerFunc) http.HandlerFunc

func LogRequestDetails

func LogRequestDetails() Adapter

LogRequestDetails logs the request details including the request method, URL, header keys and now also includes logging the latency

func SetCorsHeaders

func SetCorsHeaders() Adapter

func ValidateRestMethod

func ValidateRestMethod(method string) Adapter

ValidateRestMethod middleware to validate proper methods

type StatusRecorder added in v0.7.6

type StatusRecorder struct {
	http.ResponseWriter
	Status int
}

func (*StatusRecorder) WriteHeader added in v0.7.6

func (rec *StatusRecorder) WriteHeader(code int)

Jump to

Keyboard shortcuts

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