Documentation
¶
Index ¶
- Constants
- Variables
- type AccessLogMiddleware
- type AccessLogMiddlewareOption
- type Config
- type CorrelationIDMiddleware
- type CorrelationIDMiddlewareOption
- type CorrelationIDProvider
- type CorrelationIDProviderFunc
- type FormatApplicationJSON
- type FormatTextHTML
- type FormatTextHTMLOption
- type FormatTextPlain
- type Formatter
- type HTMLErrorView
- type Handler
- type HandlerOption
- func WithConfig(config *Config) HandlerOption
- func WithFormatter(formatter []Formatter) HandlerOption
- func WithMiddleware(middleware []MiddlewareFunc) HandlerOption
- func WithOperationWithHandler(operations []OperationWithHandlerRegisterer) HandlerOption
- func WithRouter(router Router) HandlerOption
- func WithSecuritySchemes(securityScheme []SecurityScheme) HandlerOption
- type LogField
- type LogFunc
- type MiddlewareFunc
- type MiddlewareHandler
- type OperationWithHandler
- type OperationWithHandlerRegisterer
- type Router
- type SecurityScheme
- type SecuritySchemeAPIHeaderKeyAuth
- func (s *SecuritySchemeAPIHeaderKeyAuth) Description() string
- func (s *SecuritySchemeAPIHeaderKeyAuth) In() string
- func (s *SecuritySchemeAPIHeaderKeyAuth) Key() string
- func (s *SecuritySchemeAPIHeaderKeyAuth) Name() string
- func (s *SecuritySchemeAPIHeaderKeyAuth) Scheme() string
- func (s *SecuritySchemeAPIHeaderKeyAuth) Type() string
- type SecuritySchemeAPIQueryKeyAuth
- func (s *SecuritySchemeAPIQueryKeyAuth) Description() string
- func (s *SecuritySchemeAPIQueryKeyAuth) In() string
- func (s *SecuritySchemeAPIQueryKeyAuth) Key() string
- func (s *SecuritySchemeAPIQueryKeyAuth) Name() string
- func (s *SecuritySchemeAPIQueryKeyAuth) Scheme() string
- func (s *SecuritySchemeAPIQueryKeyAuth) Type() string
- type SecuritySchemeBasicAuth
- type SecuritySchemeTokenAuth
Constants ¶
const ( // SchemeHTTP scheme name. SchemeHTTP = "http" // SchemeHTTPS scheme name. SchemeHTTPS = "https" // HeaderCorrelationID correlation ID header name. HeaderCorrelationID = "X-Correlation-ID" // HeaderForwardedProto header name. HeaderForwardedProto = "X-Forwarded-Proto" // HeaderForwardedScheme header name. HeaderForwardedScheme = "X-Forwarded-Scheme" // ContextCorrelationID context correlation ID name. ContextCorrelationID = "correlation-id" ContentTypeTextPlain = "text/plain" ContentTypeTextHTML = "text/html" ContentTypeApplicationJSON = "application/json" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AccessLogMiddleware ¶
type AccessLogMiddleware struct {
// contains filtered or unexported fields
}
AccessLogMiddleware middleware to log access events.
func NewAccessLogMiddleware ¶
func NewAccessLogMiddleware(options ...AccessLogMiddlewareOption) *AccessLogMiddleware
NewAccessLogMiddleware factory function to crate a new access log middleware instance.
type AccessLogMiddlewareOption ¶
type AccessLogMiddlewareOption func(p *AccessLogMiddleware)
AccessLogMiddlewareOption function.
func WithAccessLogMiddlewareLogFunc ¶
func WithAccessLogMiddlewareLogFunc(fn LogFunc) AccessLogMiddlewareOption
WithAccessLogMiddlewareLogFunc configuration option.
type Config ¶
type Config struct {
Title string `env:"TITLE,default=API" json:"title"`
Version string `env:"VERSION,default=v0.0.0" json:"version"`
OpenAPIPath string `env:"OPEN_API_PATH,default=/openapi" json:"openApiPath"`
DocsPath string `env:"DOCS_PATH,default=/docs" json:"docsPath"`
SchemasPath string `env:"SCHEMAS_PATH,default=/schemas" json:"schemasPath"`
DefaultFormat string `env:"DEFAULT_FORMAT,default=application/json" json:"defaultFormat"`
}
Config is a struct containing server configuration values.
type CorrelationIDMiddleware ¶
type CorrelationIDMiddleware struct {
// contains filtered or unexported fields
}
CorrelationIDMiddleware middleware to handle correlation ID.
func NewCorrelationIDMiddleware ¶
func NewCorrelationIDMiddleware(options ...CorrelationIDMiddlewareOption) *CorrelationIDMiddleware
NewCorrelationIDMiddleware factory function to crate a correlation ID handler middleware instance.
type CorrelationIDMiddlewareOption ¶
type CorrelationIDMiddlewareOption func(p *CorrelationIDMiddleware)
CorrelationIDMiddlewareOption function.
func WithCorrelationIDMiddlewareCorrelationIDProvider ¶
func WithCorrelationIDMiddlewareCorrelationIDProvider( provider CorrelationIDProvider, ) CorrelationIDMiddlewareOption
WithCorrelationIDMiddlewareCorrelationIDProvider configuration option.
type CorrelationIDProvider ¶
type CorrelationIDProvider interface {
String() string
}
CorrelationIDProvider correlation ID provider.
type CorrelationIDProviderFunc ¶
type CorrelationIDProviderFunc func() string
CorrelationIDProviderFunc correlation ID provider.
func NewUUIDCorrelationIDProvider ¶
func NewUUIDCorrelationIDProvider() CorrelationIDProviderFunc
NewUUIDCorrelationIDProvider factory function.
func (CorrelationIDProviderFunc) String ¶
func (f CorrelationIDProviderFunc) String() string
String method to get correlation ID.
type FormatApplicationJSON ¶
type FormatApplicationJSON struct{}
FormatApplicationJSON implements the Huma Format interface for a specific content type.
func NewFormatApplicationJSON ¶
func NewFormatApplicationJSON() *FormatApplicationJSON
NewFormatApplicationJSON factory function.
func (*FormatApplicationJSON) ContentType ¶
func (f *FormatApplicationJSON) ContentType() string
ContentType returns the MIME type associated with this format.
type FormatTextHTML ¶
type FormatTextHTML struct {
// contains filtered or unexported fields
}
FormatTextHTML implements the Huma Format interface for a specific content type.
func NewFormatTextHTML ¶
func NewFormatTextHTML(options ...FormatTextHTMLOption) *FormatTextHTML
NewFormatTextHTML factory function.
func (*FormatTextHTML) ContentType ¶
func (f *FormatTextHTML) ContentType() string
ContentType returns the MIME type associated with this format.
type FormatTextHTMLOption ¶
type FormatTextHTMLOption func(p *FormatTextHTML)
FormatTextHTMLOption function.
func WithFormatTextHTMLTemplate ¶
func WithFormatTextHTMLTemplate(tpl string) FormatTextHTMLOption
WithFormatTextHTMLTemplate configuration option.
type FormatTextPlain ¶
type FormatTextPlain struct{}
FormatTextPlain implements the Huma Format interface for plain text content.
func NewFormatTextPlain ¶
func NewFormatTextPlain() *FormatTextPlain
NewFormatTextPlain factory function.
func (*FormatTextPlain) ContentType ¶
func (f *FormatTextPlain) ContentType() string
ContentType returns the MIME type associated with this format.
type Formatter ¶
type Formatter interface {
ContentType() string
Marshal(writer io.Writer, v any) error
Unmarshal(data []byte, v any) error
}
Formatter input/output formatter.
type HTMLErrorView ¶
HTMLErrorView type.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler abstraction for the router to be used with Huma.
func NewHandler ¶
func NewHandler(options ...HandlerOption) *Handler
NewHandler a factory function to create a new server.
type HandlerOption ¶
type HandlerOption func(p *Handler)
HandlerOption function.
func WithFormatter ¶
func WithFormatter(formatter []Formatter) HandlerOption
WithFormatter configuration option.
func WithMiddleware ¶
func WithMiddleware(middleware []MiddlewareFunc) HandlerOption
WithMiddleware configuration option.
func WithOperationWithHandler ¶
func WithOperationWithHandler(operations []OperationWithHandlerRegisterer) HandlerOption
WithOperationWithHandler configuration option.
func WithSecuritySchemes ¶
func WithSecuritySchemes(securityScheme []SecurityScheme) HandlerOption
WithSecuritySchemes configuration option.
type MiddlewareFunc ¶
MiddlewareFunc middleware function type.
type MiddlewareHandler ¶
type MiddlewareHandler interface {
Handler(ctx huma.Context, api huma.API, next func(huma.Context))
}
MiddlewareHandler interface.
type OperationWithHandler ¶
type OperationWithHandler[I, O any] struct { huma.Operation Handler func(context.Context, *I) (*O, error) }
OperationWithHandler an operation type.
func (*OperationWithHandler[I, O]) Register ¶
func (op *OperationWithHandler[I, O]) Register(api huma.API)
Register to register operation in huma API.
type OperationWithHandlerRegisterer ¶
OperationWithHandlerRegisterer an operation with handler registerer.
type SecurityScheme ¶
type SecurityScheme interface {
Key() string
Type() string
Name() string
Description() string
Scheme() string
In() string
}
SecurityScheme interface.
type SecuritySchemeAPIHeaderKeyAuth ¶
type SecuritySchemeAPIHeaderKeyAuth struct{}
SecuritySchemeAPIHeaderKeyAuth represents an API key authentication scheme using a header.
func NewSecuritySchemeAPIHeaderKeyAuth ¶
func NewSecuritySchemeAPIHeaderKeyAuth() *SecuritySchemeAPIHeaderKeyAuth
NewSecuritySchemeAPIHeaderKeyAuth creates a new header-based API key security scheme.
func (*SecuritySchemeAPIHeaderKeyAuth) Description ¶
func (s *SecuritySchemeAPIHeaderKeyAuth) Description() string
Description returns a short description of this security scheme.
func (*SecuritySchemeAPIHeaderKeyAuth) In ¶
func (s *SecuritySchemeAPIHeaderKeyAuth) In() string
In returns the location of the authentication parameter.
func (*SecuritySchemeAPIHeaderKeyAuth) Key ¶
func (s *SecuritySchemeAPIHeaderKeyAuth) Key() string
Key returns the unique identifier for this security scheme.
func (*SecuritySchemeAPIHeaderKeyAuth) Name ¶
func (s *SecuritySchemeAPIHeaderKeyAuth) Name() string
Name returns the parameter name for this scheme.
func (*SecuritySchemeAPIHeaderKeyAuth) Scheme ¶
func (s *SecuritySchemeAPIHeaderKeyAuth) Scheme() string
Scheme returns the HTTP authentication scheme, if any.
func (*SecuritySchemeAPIHeaderKeyAuth) Type ¶
func (s *SecuritySchemeAPIHeaderKeyAuth) Type() string
Type returns the security scheme type.
type SecuritySchemeAPIQueryKeyAuth ¶
type SecuritySchemeAPIQueryKeyAuth struct{}
SecuritySchemeAPIQueryKeyAuth represents an API key authentication scheme using a query parameter.
func NewSecuritySchemeAPIQueryKeyAuth ¶
func NewSecuritySchemeAPIQueryKeyAuth() *SecuritySchemeAPIQueryKeyAuth
NewSecuritySchemeAPIQueryKeyAuth creates a new query-based API key security scheme.
func (*SecuritySchemeAPIQueryKeyAuth) Description ¶
func (s *SecuritySchemeAPIQueryKeyAuth) Description() string
Description returns a short description of this security scheme.
func (*SecuritySchemeAPIQueryKeyAuth) In ¶
func (s *SecuritySchemeAPIQueryKeyAuth) In() string
In returns the location of the authentication parameter.
func (*SecuritySchemeAPIQueryKeyAuth) Key ¶
func (s *SecuritySchemeAPIQueryKeyAuth) Key() string
Key returns the unique identifier for this security scheme.
func (*SecuritySchemeAPIQueryKeyAuth) Name ¶
func (s *SecuritySchemeAPIQueryKeyAuth) Name() string
Name returns the parameter name for this scheme.
func (*SecuritySchemeAPIQueryKeyAuth) Scheme ¶
func (s *SecuritySchemeAPIQueryKeyAuth) Scheme() string
Scheme returns the HTTP authentication scheme, if any.
func (*SecuritySchemeAPIQueryKeyAuth) Type ¶
func (s *SecuritySchemeAPIQueryKeyAuth) Type() string
Type returns the security scheme type.
type SecuritySchemeBasicAuth ¶
type SecuritySchemeBasicAuth struct{}
SecuritySchemeBasicAuth represents a basic HTTP authentication scheme.
func NewSecuritySchemeBasicAuth ¶
func NewSecuritySchemeBasicAuth() *SecuritySchemeBasicAuth
NewSecuritySchemeBasicAuth creates a new basic auth security scheme.
func (*SecuritySchemeBasicAuth) Description ¶
func (s *SecuritySchemeBasicAuth) Description() string
Description returns a short description of this security scheme.
func (*SecuritySchemeBasicAuth) In ¶
func (s *SecuritySchemeBasicAuth) In() string
In returns the location of the authentication parameter.
func (*SecuritySchemeBasicAuth) Key ¶
func (s *SecuritySchemeBasicAuth) Key() string
Key returns the unique identifier for this security scheme.
func (*SecuritySchemeBasicAuth) Name ¶
func (s *SecuritySchemeBasicAuth) Name() string
Name returns the parameter name for this scheme, if any.
func (*SecuritySchemeBasicAuth) Scheme ¶
func (s *SecuritySchemeBasicAuth) Scheme() string
Scheme returns the HTTP authentication scheme.
func (*SecuritySchemeBasicAuth) Type ¶
func (s *SecuritySchemeBasicAuth) Type() string
Type returns the security scheme type.
type SecuritySchemeTokenAuth ¶
type SecuritySchemeTokenAuth struct{}
SecuritySchemeTokenAuth represents a bearer token authentication scheme.
func NewSecuritySchemeTokenAuth ¶
func NewSecuritySchemeTokenAuth() *SecuritySchemeTokenAuth
NewSecuritySchemeTokenAuth creates a new token-based authentication scheme.
func (*SecuritySchemeTokenAuth) Description ¶
func (s *SecuritySchemeTokenAuth) Description() string
Description returns a short description of this security scheme.
func (*SecuritySchemeTokenAuth) In ¶
func (s *SecuritySchemeTokenAuth) In() string
In returns the location of the authentication parameter.
func (*SecuritySchemeTokenAuth) Key ¶
func (s *SecuritySchemeTokenAuth) Key() string
Key returns the unique identifier for this security scheme.
func (*SecuritySchemeTokenAuth) Name ¶
func (s *SecuritySchemeTokenAuth) Name() string
Name returns the parameter name for this scheme.
func (*SecuritySchemeTokenAuth) Scheme ¶
func (s *SecuritySchemeTokenAuth) Scheme() string
Scheme returns the HTTP authentication scheme.
func (*SecuritySchemeTokenAuth) Type ¶
func (s *SecuritySchemeTokenAuth) Type() string
Type returns the security scheme type.