Documentation
¶
Index ¶
- Variables
- func NewHandler[I, O any](call Handler[I, O]) http.HandlerFunc
- func NoopMiddleware(h http.Handler) http.Handler
- func RequestFromContext(ctx context.Context) *http.Request
- func RequestWithContext(ctx context.Context, r *http.Request) context.Context
- func WriterFromContext(ctx context.Context) http.ResponseWriter
- func WriterWithContext(ctx context.Context, w http.ResponseWriter) context.Context
- type Error
- type ErrorSpec
- type Handler
- type HandlerMeta
- func RegisterGet[I, O any](r *Router, operationID string, handler Handler[I, O], ...) *HandlerMeta
- func RegisterHandler(r *Router, handler http.Handler, meta HandlerMeta, middlewares ...Middleware) *HandlerMeta
- func RegisterHandlerFunc(r *Router, meta HandlerMeta, h http.HandlerFunc, middlewares ...Middleware) *HandlerMeta
- func RegisterPost[I, O any](r *Router, operationID string, handler Handler[I, O], ...) *HandlerMeta
- type KeyValueSpec
- type Middleware
- type Opts
- type PrimitiveType
- type Router
- type Spec
- type Validation
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalOpts = Opts{ ProcessErr: nil, MapCodeToStatus: func(code string) int { if code == "" { return http.StatusInternalServerError } return http.StatusBadRequest }, }
Functions ¶
func NewHandler ¶
func NewHandler[I, O any](call Handler[I, O]) http.HandlerFunc
func RequestWithContext ¶
func WriterFromContext ¶
func WriterFromContext(ctx context.Context) http.ResponseWriter
func WriterWithContext ¶
Types ¶
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message,omitempty"`
Meta map[string]string `json:"meta,omitempty,omitzero"`
Err error `json:"-"`
}
func (*Error) JsonString ¶
type ErrorSpec ¶
type ErrorSpec struct {
Code string
Description string
Meta []KeyValueSpec
}
type HandlerMeta ¶
func RegisterGet ¶
func RegisterGet[I, O any](r *Router, operationID string, handler Handler[I, O], middlewares ...Middleware) *HandlerMeta
func RegisterHandler ¶
func RegisterHandler(r *Router, handler http.Handler, meta HandlerMeta, middlewares ...Middleware) *HandlerMeta
func RegisterHandlerFunc ¶
func RegisterHandlerFunc(r *Router, meta HandlerMeta, h http.HandlerFunc, middlewares ...Middleware) *HandlerMeta
func RegisterPost ¶
func RegisterPost[I, O any](r *Router, operationID string, handler Handler[I, O], middlewares ...Middleware) *HandlerMeta
func (*HandlerMeta) SetSpec ¶
func (m *HandlerMeta) SetSpec(spec Spec)
type KeyValueSpec ¶
type KeyValueSpec struct {
Key string
ValueType PrimitiveType
ValueExample string
Description string
Validation Validation
}
type PrimitiveType ¶
type PrimitiveType string
const ( Bool PrimitiveType = "bool" Int PrimitiveType = "int" Uint PrimitiveType = "uint" Float64 PrimitiveType = "float64" // Array Type = "array" // Map Type = "map" String PrimitiveType = "string" )
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Meta ¶
func (r *Router) Meta() []HandlerMeta
type Spec ¶
type Spec struct {
Description string
RequestHeaders KeyValueSpec
ResponseHeaders KeyValueSpec
Errors map[int][]ErrorSpec
}
Click to show internal directories.
Click to hide internal directories.