openapi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package openapi adapts oapi-codegen's strict std-http server to handlers' route table, guard, error writer, and kin-openapi request validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(mux *http.ServeMux, routes []handlers.Route, g handlers.Guard, spec *openapi3.T, register func(*Router), opts ...handlers.Option)

Mount calls register with a Router over mux, then panics if a route of routes wasn't registered. It panics on a nil mux, spec or register.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router implements oapi-codegen's ServeMux interface.

func (*Router) HandleFunc

func (r *Router) HandleFunc(pattern string, h func(http.ResponseWriter, *http.Request))

HandleFunc registers pattern from oapi-codegen (<METHOD> <prefix><path>) on the underlying Mount with request validation against the OpenAPI spec.

func (*Router) RequestError

func (r *Router) RequestError(w http.ResponseWriter, req *http.Request, err error)

RequestError handles oapi-codegen parameter/body binding errors, writing ErrTooLarge for *http.MaxBytesError or ErrInvalidRequest otherwise, and logging the cause at debug level.

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP delegates to the mux passed to Mount.

func (*Router) WriteError

func (r *Router) WriteError(w http.ResponseWriter, req *http.Request, err error)

WriteError writes a handler error through Mount's configured ErrorWriter.

Jump to

Keyboard shortcuts

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