Documentation
¶
Index ¶
- func CORS(allowedOrigins []string) func(http.Handler) http.Handler
- func NewResponseErrorHandler(reporter ErrorReporter) func(http.ResponseWriter, *http.Request, error)
- func OpenAPIValidation(spec *openapi3.T, verifier appauth.TokenVerifier) func(http.Handler) http.Handler
- func Recovery(logger *slog.Logger, next http.Handler) http.Handler
- func RequestErrorHandler(w http.ResponseWriter, r *http.Request, err error)
- func WriteProblem(w http.ResponseWriter, status int, title string, detail string)
- type ErrorReporter
- type Health
- type Pinger
- type Problem
- type Responder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResponseErrorHandler ¶
func NewResponseErrorHandler( reporter ErrorReporter, ) func( http.ResponseWriter, *http.Request, error, )
func OpenAPIValidation ¶
func RequestErrorHandler ¶
func RequestErrorHandler( w http.ResponseWriter, r *http.Request, err error, )
func WriteProblem ¶
func WriteProblem( w http.ResponseWriter, status int, title string, detail string, )
Types ¶
type ErrorReporter ¶
type Responder ¶
type Responder[R, T any] struct { // OK builds the success response from the service value. OK func(T) R // NotFound is the response for a service result that reports no match. // Leave it zero for operations whose spec declares no 404. NotFound R }
Responder binds the response types of one generated operation, so handlers can feed a service result straight in and stay a single line.
R is the operation's response interface (e.g. usersapi.GetUserResponseObject) and T the value the service returns. Each operation gets its own concrete 404 type from the generator, which is why NotFound is a field rather than something a plain function could return.
func (Responder[R, T]) Exists ¶
Exists completes an operation whose service call only reports whether the target existed, such as a delete.
Click to show internal directories.
Click to hide internal directories.