Documentation
¶
Index ¶
- Variables
- func Interface(i any, ts ...any) *vary.Interface
- func NewSchemas() jschema.Schemas
- type DataBinary
- type Descriptioner
- type Group
- func (g *Group) Add(method openapi.Method, path string, handler OperationHandler)
- func (g *Group) DELETE(path string, handler OperationHandler)
- func (g *Group) GET(path string, handler OperationHandler)
- func (g *Group) Group(prefix string) *Group
- func (g *Group) HEAD(path string, handler OperationHandler)
- func (g *Group) Handler(h http.Handler) http.Handler
- func (g *Group) OPTIONS(path string, handler OperationHandler)
- func (r *Group) OpenAPI() *openapi.Document
- func (g *Group) PATCH(path string, handler OperationHandler)
- func (g *Group) POST(path string, handler OperationHandler)
- func (g *Group) PUT(path string, handler OperationHandler)
- func (g *Group) Prefix() string
- func (g *Group) Router() *Router
- func (g *Group) Server() http.Handler
- func (g *Group) Shutdown(ctx context.Context) error
- func (g *Group) Start(addr string) error
- func (g *Group) Use(m middlewares.Middleware)
- type InBody
- type InHeader
- type InURL
- type Operation
- type OperationHandler
- type OperationOpenAPI
- type Params
- type Path
- type Response
- type Router
- func (r *Router) AddFormatChecker(name string, c gojsonschema.FormatChecker)
- func (r *Router) Group(prefix string) *Group
- func (r *Router) Handler(next http.Handler) http.Handler
- func (r *Router) OpenAPI() *openapi.Document
- func (r *Router) ServerHandler() http.Handler
- func (r *Router) Shutdown(ctx context.Context) error
- func (r *Router) Start(addr string) error
- func (r *Router) Use(middlewares ...middlewares.Middleware)
- type StatusAccepted
- type StatusAlreadyReported
- type StatusBadGateway
- type StatusBadRequest
- type StatusConflict
- type StatusContinue
- type StatusCreated
- type StatusEarlyHints
- type StatusExpectationFailed
- type StatusFailedDependency
- type StatusForbidden
- type StatusFound
- type StatusGatewayTimeout
- type StatusGone
- type StatusHTTPVersionNotSupported
- type StatusIMUsed
- type StatusInsufficientStorage
- type StatusInternalServerError
- type StatusLengthRequired
- type StatusLocked
- type StatusLoopDetected
- type StatusMethodNotAllowed
- type StatusMisdirectedRequest
- type StatusMovedPermanently
- type StatusMultiStatus
- type StatusMultipleChoices
- type StatusNetworkAuthenticationRequired
- type StatusNoContent
- type StatusNonAuthoritativeInfo
- type StatusNotAcceptable
- type StatusNotExtended
- type StatusNotFound
- type StatusNotImplemented
- type StatusNotModified
- type StatusOK
- type StatusPartialContent
- type StatusPaymentRequired
- type StatusPermanentRedirect
- type StatusPreconditionFailed
- type StatusPreconditionRequired
- type StatusProcessing
- type StatusProxyAuthRequired
- type StatusRequestEntityTooLarge
- type StatusRequestHeaderFieldsTooLarge
- type StatusRequestTimeout
- type StatusRequestURITooLong
- type StatusRequestedRangeNotSatisfiable
- type StatusResetContent
- type StatusSeeOther
- type StatusServiceUnavailable
- type StatusSwitchingProtocols
- type StatusTeapot
- type StatusTemporaryRedirect
- type StatusTooEarly
- type StatusTooManyRequests
- type StatusUnauthorized
- type StatusUnavailableForLegalReasons
- type StatusUnprocessableEntity
- type StatusUnsupportedMediaType
- type StatusUpgradeRequired
- type StatusUseProxy
- type StatusVariantAlsoNegotiates
Constants ¶
This section is empty.
Variables ¶
var ErrMissingParam = errors.New("missing parameter in request")
Functions ¶
func Interface ¶ added in v0.2.0
Interface create a interface set of i. ts are the types that implement i. For golang runtime we can't reflect all the implementations of an interface, with it goapi can find out all the possible response type of an endpoint.
func NewSchemas ¶ added in v0.6.0
Types ¶
type DataBinary ¶ added in v0.6.0
type DataBinary []byte
type Descriptioner ¶ added in v0.3.0
type Descriptioner interface {
Description() string
}
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Add ¶
func (g *Group) Add(method openapi.Method, path string, handler OperationHandler)
func (*Group) DELETE ¶
func (g *Group) DELETE(path string, handler OperationHandler)
func (*Group) GET ¶
func (g *Group) GET(path string, handler OperationHandler)
func (*Group) HEAD ¶
func (g *Group) HEAD(path string, handler OperationHandler)
func (*Group) Handler ¶ added in v0.2.0
Use is a shortcut for Router.Handler.
func (*Group) OPTIONS ¶
func (g *Group) OPTIONS(path string, handler OperationHandler)
func (*Group) OpenAPI ¶
OpenAPI is a shortcut for Router.OpenAPI.
func (*Group) PATCH ¶
func (g *Group) PATCH(path string, handler OperationHandler)
func (*Group) POST ¶
func (g *Group) POST(path string, handler OperationHandler)
func (*Group) PUT ¶
func (g *Group) PUT(path string, handler OperationHandler)
func (*Group) Server ¶
Handler is a shortcut for Router.Handler.
func (*Group) Shutdown ¶ added in v0.2.0
Shutdown is a shortcut for Router.Shutdown.
func (*Group) Start ¶ added in v0.2.0
Start is a shortcut for Router.Start.
func (*Group) Use ¶
func (g *Group) Use(m middlewares.Middleware)
Use is similar to Router.Use but with he group prefix.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation is a handler for a specific HTTP method and path. We use reflection to constrain the handler function signature, to make it follow the openapi spec.
type OperationHandler ¶ added in v0.6.0
type OperationHandler any
OperationHandler is a function to handle input and output of a http operation.
type OperationOpenAPI ¶ added in v0.6.0
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path helps to handle openapi path pattern.
type Response ¶
type Response interface {
// contains filtered or unexported methods
}
Response is an interface that represents a response object.
type Router ¶
Router itself is a middleware.
func (*Router) AddFormatChecker ¶ added in v0.6.0
func (r *Router) AddFormatChecker(name string, c gojsonschema.FormatChecker)
AddFormatChecker for json schema validation. Such as a struct:
type User struct { ID string `format:"my-id"` }
You can add a format checker for "id" like:
AddFormatChecker("my-id", checker)
func (*Router) OpenAPI ¶
OpenAPI returns the OpenAPI doc of the router. You can use json.Marshal to convert it to a JSON string.
func (*Router) ServerHandler ¶ added in v0.2.0
ServerHandler with a 404 middleware at the end.
func (*Router) Start ¶ added in v0.2.0
Start listen on addr with the Router.ServerHandler.
func (*Router) Use ¶
func (r *Router) Use(middlewares ...middlewares.Middleware)
Use a middleware to the router.
type StatusHTTPVersionNotSupported ¶
type StatusHTTPVersionNotSupported struct{}
StatusHTTPVersionNotSupported 505.
type StatusInsufficientStorage ¶
type StatusInsufficientStorage struct{}
StatusInsufficientStorage 507.
type StatusInternalServerError ¶
type StatusInternalServerError struct{}
StatusInternalServerError 500.
type StatusMisdirectedRequest ¶
type StatusMisdirectedRequest struct{}
StatusMisdirectedRequest 421.
type StatusNetworkAuthenticationRequired ¶
type StatusNetworkAuthenticationRequired struct{}
StatusNetworkAuthenticationRequired 511.
type StatusNonAuthoritativeInfo ¶
type StatusNonAuthoritativeInfo struct{}
StatusNonAuthoritativeInfo 203.
type StatusPreconditionFailed ¶
type StatusPreconditionFailed struct{}
StatusPreconditionFailed 412.
type StatusPreconditionRequired ¶
type StatusPreconditionRequired struct{}
StatusPreconditionRequired 428.
type StatusRequestEntityTooLarge ¶
type StatusRequestEntityTooLarge struct{}
StatusRequestEntityTooLarge 413.
type StatusRequestHeaderFieldsTooLarge ¶
type StatusRequestHeaderFieldsTooLarge struct{}
StatusRequestHeaderFieldsTooLarge 431.
type StatusRequestedRangeNotSatisfiable ¶
type StatusRequestedRangeNotSatisfiable struct{}
StatusRequestedRangeNotSatisfiable 416.
type StatusServiceUnavailable ¶
type StatusServiceUnavailable struct{}
StatusServiceUnavailable 503.
type StatusSwitchingProtocols ¶
type StatusSwitchingProtocols struct{}
StatusSwitchingProtocols 101.
type StatusUnavailableForLegalReasons ¶
type StatusUnavailableForLegalReasons struct{}
StatusUnavailableForLegalReasons 451.
type StatusUnprocessableEntity ¶
type StatusUnprocessableEntity struct{}
StatusUnprocessableEntity 422.
type StatusUnsupportedMediaType ¶
type StatusUnsupportedMediaType struct{}
StatusUnsupportedMediaType 415.
type StatusVariantAlsoNegotiates ¶
type StatusVariantAlsoNegotiates struct{}
StatusVariantAlsoNegotiates 506.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
lib
|
|
examples/basic
command
|
|
examples/hello-world
command
|
|
gen-status-code
command
|
|
examples/as-echo-middleware
module
|
|
examples/as-gin-middleware
module
|