Documentation
¶
Index ¶
- Variables
- func Interface(i any) *vary.Interface
- type ConfigOperation
- type Descriptioner
- type Error
- type Group
- func (g *Group) Add(method openapi.Method, path string, handler any, opts ...ConfigOperation)
- func (g *Group) DELETE(path string, handler any, opts ...ConfigOperation)
- func (g *Group) GET(path string, handler any, opts ...ConfigOperation)
- func (g *Group) Group(prefix string) *Group
- func (g *Group) HEAD(path string, handler any, opts ...ConfigOperation)
- func (g *Group) Handler(h http.Handler) http.Handler
- func (g *Group) OPTIONS(path string, handler any, opts ...ConfigOperation)
- func (r *Group) OpenAPI(schemas *jschema.Schemas) *openapi.Document
- func (g *Group) PATCH(path string, handler any, opts ...ConfigOperation)
- func (g *Group) POST(path string, handler any, opts ...ConfigOperation)
- func (g *Group) PUT(path string, handler any, opts ...ConfigOperation)
- 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 Middleware)
- type InBody
- type InHeader
- type InURL
- type Middleware
- type MiddlewareFunc
- type Operation
- type OperationMeta
- type Params
- type Path
- type Response
- type Router
- func (r *Router) Group(prefix string) *Group
- func (r *Router) Handler(next http.Handler) http.Handler
- func (r *Router) OpenAPI(schemas *jschema.Schemas) *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 ...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 ¶
Types ¶
type ConfigOperation ¶
type ConfigOperation func(op *Operation)
func OperationID ¶ added in v0.3.0
func OperationID(id string) ConfigOperation
OperationID for the operation.
type Descriptioner ¶ added in v0.3.0
type Descriptioner interface {
Description() string
}
type Error ¶
type Error struct { // Code is a machine-readable error code. Code string `json:"code,omitempty"` // Message is a human-readable error message. Message string `json:"message,omitempty"` // Target is a human-readable description of the target of the error. Target string `json:"target,omitempty"` // Details is an array of structured error details objects. Details []Error `json:"details,omitempty"` // InnerError is a generic error object that is used by the service developer for debugging. InnerError any `json:"innererror,omitempty"` }
Error is an error object that contains information about a failed request. Reference: https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#error--object
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Handler ¶ added in v0.2.0
Use is a shortcut for Router.Handler.
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.
type Middleware ¶
type Middleware interface { // A Middleware https://cs.opensource.google/go/x/pkgsite/+/68be0dd1:internal/middleware/middleware.go Handler(next http.Handler) http.Handler }
type MiddlewareFunc ¶
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 OperationMeta ¶
type OperationMeta struct { // Summary is used for display in the openapi UI. Summary string // Description is used for display in the openapi UI. Description string // OperationID is a unique string used to identify an individual operation. // This can be used by tools and libraries to provide functionality for // referencing and calling the operation from different parts of your application. OperationID string // Tags are used for grouping operations together for display in the openapi UI. Tags []string }
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) 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) Use ¶
func (r *Router) Use(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
|