Documentation
¶
Index ¶
- func Delete[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- func Get[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- func Head[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- func NewHTTPError(status int, detail string) error
- func Options[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- func Patch[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- func Post[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- func Put[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
- type App
- func (app *App) Group(prefix string, opts ...OperationOption) *Group
- func (app *App) Provide(dependencies ...DependencyResolver)
- func (app *App) RegisterSecurity(schemes ...SecurityScheme)
- func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (app *App) Use(middlewares ...Middleware)
- type Attachment
- type Config
- type Dependency
- type DependencyResolver
- type FieldError
- type File
- type Group
- type HTML
- type HTTPError
- type Handler
- type Middleware
- type NoContent
- type Operation
- type OperationOption
- func Description(description string) OperationOption
- func OperationID(id string) OperationOption
- func Require(dependencies ...DependencyResolver) OperationOption
- func Security(names ...string) OperationOption
- func Status(status int) OperationOption
- func Summary(summary string) OperationOption
- func Tags(tags ...string) OperationOption
- func Use(middlewares ...Middleware) OperationOption
- type Problem
- type Redirect
- type Response
- type Router
- type SSE
- type SSEEvent
- type SecurityScheme
- type Stream
- type Text
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
Delete registers a typed DELETE operation.
func Get ¶
func Get[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
Get registers a typed GET operation.
func Head ¶
func Head[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
Head registers a typed HEAD operation.
func NewHTTPError ¶
NewHTTPError creates an error that handlers can return to control HTTP status.
func Options ¶
func Options[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
Options registers a typed OPTIONS operation.
func Patch ¶
func Patch[In any, Out any](router Router, path string, handler Handler[In, Out], opts ...OperationOption)
Patch registers a typed PATCH operation.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is a net/http-compatible application.
func (*App) Group ¶
func (app *App) Group(prefix string, opts ...OperationOption) *Group
Group creates a route group below the app.
func (*App) Provide ¶
func (app *App) Provide(dependencies ...DependencyResolver)
Provide registers app-level dependencies.
func (*App) RegisterSecurity ¶
func (app *App) RegisterSecurity(schemes ...SecurityScheme)
RegisterSecurity adds OpenAPI security schemes to the app.
func (*App) ServeHTTP ¶
func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*App) Use ¶
func (app *App) Use(middlewares ...Middleware)
Use appends middleware to routes registered after this call.
type Attachment ¶
type Attachment struct {
Status int
Headers http.Header
Path string
Filename string
ContentType string
}
Attachment streams a file with Content-Disposition: attachment.
type Dependency ¶
type Dependency[T any] struct { Name string Resolver func(context.Context, *http.Request) (T, error) }
Dependency resolves a request-scoped value that can be injected into input structs.
func APIKeyHeaderDep ¶
func APIKeyHeaderDep(name, header string) Dependency[string]
APIKeyHeaderDep injects an API key from a header into a dep-tagged field.
func APIKeyQueryDep ¶
func APIKeyQueryDep(name, query string) Dependency[string]
APIKeyQueryDep injects an API key from a query parameter into a dep-tagged field.
func BearerTokenDep ¶
func BearerTokenDep(name string) Dependency[string]
BearerTokenDep injects the Authorization bearer token into a dep-tagged field.
type DependencyResolver ¶
type DependencyResolver interface {
// contains filtered or unexported methods
}
type FieldError ¶
type FieldError struct {
Field string `json:"field"`
Message string `json:"message"`
Code string `json:"code"`
}
FieldError describes a field-level binding or validation error.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group registers routes under a shared path prefix and middleware stack.
func (*Group) Group ¶
func (group *Group) Group(prefix string, opts ...OperationOption) *Group
Group creates a nested route group.
func (*Group) Use ¶
func (group *Group) Use(middlewares ...Middleware)
Use appends middleware to routes registered on the group after this call.
type Middleware ¶
Middleware is standard Go HTTP middleware.
type Operation ¶
type Operation struct {
OperationID string
Summary string
Description string
Tags []string
Status int
// contains filtered or unexported fields
}
Operation stores metadata used by routing and OpenAPI generation.
type OperationOption ¶
type OperationOption func(*Operation)
OperationOption configures route metadata.
func Description ¶
func Description(description string) OperationOption
Description sets the OpenAPI description.
func OperationID ¶
func OperationID(id string) OperationOption
OperationID sets the OpenAPI operationId.
func Require ¶
func Require(dependencies ...DependencyResolver) OperationOption
Require registers route-level dependencies.
func Security ¶
func Security(names ...string) OperationOption
Security adds an OpenAPI security requirement by scheme name.
func Use ¶
func Use(middlewares ...Middleware) OperationOption
Use adds middleware to a route or group.
type Problem ¶
type Problem struct {
Type string `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
Errors []FieldError `json:"errors,omitempty"`
}
Problem is an RFC 9457 Problem Details response.
type Router ¶
type Router interface {
// contains filtered or unexported methods
}
Router is implemented by App and Group route targets.
type SecurityScheme ¶
SecurityScheme describes an OpenAPI security scheme.
func APIKeyCookie ¶
func APIKeyCookie(name, cookie string) SecurityScheme
APIKeyCookie defines an API key security scheme read from a cookie.
func APIKeyHeader ¶
func APIKeyHeader(name, header string) SecurityScheme
APIKeyHeader defines an API key security scheme read from a header.
func APIKeyQuery ¶
func APIKeyQuery(name, query string) SecurityScheme
APIKeyQuery defines an API key security scheme read from a query parameter.
func BasicAuth ¶
func BasicAuth(name string) SecurityScheme
BasicAuth defines an HTTP basic security scheme.
func BearerAuth ¶
func BearerAuth(name string) SecurityScheme
BearerAuth defines an HTTP bearer security scheme.
type Validator ¶
type Validator interface {
ValidateGapi() []FieldError
}
Validator can be implemented by input or nested model types for custom validation.