Documentation ¶
Index ¶
- Constants
- func LoadRawJson(loadRawJson func() ([]byte, error)) http.HandlerFunc
- func RawJson(data []byte) http.HandlerFunc
- func RegisterDecoder[T DecoderConstraint](contentType string, dec T, aliases ...string)
- type API
- func (r *API) Delete(path string, handle http.Handler)
- func (r *API) Get(path string, handle http.Handler)
- func (r *API) Group(path string) Router
- func (r *API) Handle(method, path string, handle http.Handler)
- func (r *API) HandleFunc(method, path string, handle http.HandlerFunc)
- func (r *API) Patch(path string, handle http.Handler)
- func (r *API) Post(path string, handle http.Handler)
- func (r *API) Put(path string, handle http.Handler)
- func (r *API) Router() http.Handler
- func (r *API) Use(mw ...Middleware)
- type Config
- type ContextUnmarshaler
- type DecoderConstraint
- type DecoderFactory
- type Empty
- type Handle
- type Handler
- type Headerer
- type Middleware
- type Problemer
- type RequestParser
- type Router
- type StatusCoder
- type Unmarshaler
Constants ¶
View Source
const JsonEncoding = "application/json"
Variables ¶
This section is empty.
Functions ¶
func LoadRawJson ¶
func LoadRawJson(loadRawJson func() ([]byte, error)) http.HandlerFunc
LoadRawJson loads raw json to response useful for swagger docs.
func RawJson ¶
func RawJson(data []byte) http.HandlerFunc
RawJson sends raw json to response useful for swagger docs.
func RegisterDecoder ¶
func RegisterDecoder[T DecoderConstraint](contentType string, dec T, aliases ...string)
RegisterDecoder registers a request decoder.
Types ¶
type API ¶
type API struct { NotFound http.Handler MethodNotAllowed http.Handler PanicHandler func(http.ResponseWriter, *http.Request, interface{}) // contains filtered or unexported fields }
func (*API) HandleFunc ¶
func (r *API) HandleFunc(method, path string, handle http.HandlerFunc)
HandleFunc handles the requests with the specified method.
func (*API) Use ¶
func (r *API) Use(mw ...Middleware)
Use will register middleware to run prior to the handlers.
type Config ¶
type Config struct { // the function to call for logging route details RouteLogFunc func(ctx context.Context, route string, params map[string]string) // the function to call for logging problems ProblemLogFunc func(ctx context.Context, p *problem.Problem) problem.ProblemConfig }
func GetDefaultConfig ¶
func GetDefaultConfig() *Config
GetDefaultConfig will return default problem config.
type ContextUnmarshaler ¶
type DecoderConstraint ¶
type DecoderConstraint interface { Unmarshaler | ContextUnmarshaler | DecoderFactory | RequestParser }
type DecoderFactory ¶
type RequestParser ¶
type Router ¶
type Router interface { Get(path string, handle http.Handler) Post(path string, handle http.Handler) Put(path string, handle http.Handler) Delete(path string, handle http.Handler) Handle(method, path string, handle http.Handler) HandleFunc(method, path string, handle http.HandlerFunc) Group(path string) Router Use(mw ...Middleware) }
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
StatusCoder allows you to customise the HTTP response code.
type Unmarshaler ¶
Click to show internal directories.
Click to hide internal directories.