Documentation
¶
Index ¶
- Variables
- func APIVersionFromContext(ctx context.Context) (string, bool)
- func CacheControlHeaders(maxAge time.Duration) http.Header
- func ConfigureFieldMetadata(model any, fieldGoName string, cfg FieldMetadataConfig) error
- func DefaultDocsHTML(openapiPath string) string
- func FlattenIncludeTree(tree IncludeTree) []string
- func Handle[Input any, Output any](e *Engine, method, path, operationID string, ...)
- func HandleErr[Input any](e *Engine, method, path, operationID string, ...)
- func HandleGroup[Input any, Output any](g *Group, method, path, operationID string, ...)
- func HandleOut[Input any, Output any](e *Engine, method, path, operationID string, ...)
- func HandleRawTyped[Input any](e *Engine, method, path, operationID string, ...)
- func HandleSSE[Input any](e *Engine, method, path, operationID string, ...)
- func HandleStreamTyped[Input any](e *Engine, method, path, operationID string, ...)
- func HandleWebSocket[Input any](e *Engine, method, path, operationID string, cfg WSConfig, ...)
- func HasInclude(ctx context.Context, path string) bool
- func IncludesFromContext(ctx context.Context) []string
- func ParseIncludes(raw string, allowlist []string) ([]string, error)
- func RegisterValidator[T any](e *Engine, fn func(*T) error)
- func TenantFromContext(ctx context.Context) (string, bool)
- func ValidateOpenAPIQuality(spec map[string]any, gates OpenAPIQualityGates) []string
- func WithAPIVersion(ctx context.Context, version string) context.Context
- func WithIncludes(ctx context.Context, includes []string) context.Context
- func WithListQueryDTO(ctx context.Context, dto ListQueryDTO) context.Context
- type APIError
- type APIVersionSource
- type APIVersioningConfig
- type CacheConfig
- type CacheInvalidationConfig
- type Encoder
- type Engine
- func (e *Engine) AddObserver(obs Observer)
- func (e *Engine) AddOpenAPIServer(url, description string)
- func (e *Engine) Group(prefix string, middleware ...Middleware) *Group
- func (e *Engine) IsReady() bool
- func (e *Engine) MarshalOpenAPIJSON() ([]byte, error)
- func (e *Engine) MarshalOpenAPIYAML() ([]byte, error)
- func (e *Engine) OpenAPISpec() map[string]any
- func (e *Engine) Operations() []Operation
- func (e *Engine) RegisterEncoder(contentType string, enc Encoder)
- func (e *Engine) RegisterHealthRoutes()
- func (e *Engine) RegisterOpenAPISecurityScheme(name string, scheme map[string]any)
- func (e *Engine) RegisterRaw(method, path, operationID string, h Handler, middleware ...Middleware)
- func (e *Engine) RegisterSchemaRoutes(listPath, itemPath string)
- func (e *Engine) RegisterSystemRoutes(openapiPath, docsPath string)
- func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (e *Engine) SetEncoder(enc Encoder)
- func (e *Engine) SetErrorMapper(m ErrorMapper)
- func (e *Engine) SetOpenAPIServers(servers []map[string]any)
- func (e *Engine) SetReady(v bool)
- func (e *Engine) Use(mw ...Middleware)
- func (e *Engine) Version(version string, middleware ...Middleware) *Group
- type ErrorDetail
- type ErrorMapper
- type FieldMetadataConfig
- type Group
- func (g *Group) Group(prefix string, middleware ...Middleware) *Group
- func (g *Group) WithAcceptVersioning(param string, required bool, defaultVersion string) *Group
- func (g *Group) WithCallbacks(callbacks map[string]any) *Group
- func (g *Group) WithHeaderVersioning(header string, required bool, defaultVersion string) *Group
- func (g *Group) WithIncludeAllowlist(paths ...string) *Group
- func (g *Group) WithIncludeParamName(name string) *Group
- func (g *Group) WithMetadata(items map[string]string) *Group
- func (g *Group) WithQueryDTO() *Group
- func (g *Group) WithQueryVersioning(param string, required bool, defaultVersion string) *Group
- func (g *Group) WithSecurity(items ...string) *Group
- func (g *Group) WithTags(tags ...string) *Group
- func (g *Group) WithVersion(version string) *Group
- func (g *Group) WithVersioning(cfg APIVersioningConfig) *Group
- type HMACJWTVerifier
- type Handler
- type IncludeTree
- type JSONEncoder
- type JWTVerifier
- type ListQueryDTO
- type Middleware
- func APIVersioning(cfg APIVersioningConfig) Middleware
- func CacheResponses(ttl time.Duration) Middleware
- func CacheResponsesWithConfig(cfg CacheConfig) Middleware
- func InvalidateCacheOnWrite(cfg CacheInvalidationConfig) Middleware
- func Logger(logger *log.Logger) Middleware
- func Recovery() Middleware
- func TenantExtractor(extractors ...TenantResolveFunc) Middleware
- type Observer
- type ObserverFunc
- type OpenAPIQualityGates
- type Operation
- type OperationParam
- type OperationRegistry
- func (r *OperationRegistry) Add(op Operation)
- func (r *OperationRegistry) JSONSchemaForType(model any) map[string]any
- func (r *OperationRegistry) JSONSchemas() map[string]any
- func (r *OperationRegistry) List() []Operation
- func (r *OperationRegistry) MarshalJSONSchemasJSON() ([]byte, error)
- func (r *OperationRegistry) MarshalOpenAPIJSON() ([]byte, error)
- func (r *OperationRegistry) MarshalOpenAPIYAML() ([]byte, error)
- func (r *OperationRegistry) OpenAPISpec() map[string]any
- func (r *OperationRegistry) RegisterSecurityScheme(name string, scheme map[string]any)
- func (r *OperationRegistry) SetServers(servers []map[string]any)
- func (r *OperationRegistry) Update(method, path, operationID string, fn func(*Operation))
- type Optional
- func (o Optional[T]) IsNull() bool
- func (o Optional[T]) IsSet() bool
- func (o Optional[T]) IsZero() bool
- func (o Optional[T]) MarshalJSON() ([]byte, error)
- func (o Optional[T]) OptionalIsNull() bool
- func (o Optional[T]) OptionalIsSet() bool
- func (o Optional[T]) OptionalValueAny() any
- func (o *Optional[T]) Set(v T)
- func (o *Optional[T]) SetNull()
- func (o *Optional[T]) UnmarshalJSON(data []byte) error
- func (o *Optional[T]) UnmarshalText(text []byte) error
- func (o *Optional[T]) Unset()
- func (o Optional[T]) Value() (T, bool)
- type OptionalBool
- type OptionalInt
- type OptionalString
- type ProblemExampleSpec
- type RawResponse
- type RequestContext
- type Response
- type ResponseCache
- type Route
- type RouteOption
- func WithCallbacks(callbacks map[string]any) RouteOption
- func WithIncludeAllowlist(paths ...string) RouteOption
- func WithIncludeParamName(name string) RouteOption
- func WithMetadata(items map[string]string) RouteOption
- func WithMiddleware(mw ...Middleware) RouteOption
- func WithProblemResponseSpec(spec map[int]ProblemExampleSpec) RouteOption
- func WithProblemResponses(statuses ...int) RouteOption
- func WithQueryDTO() RouteOption
- func WithRequestExamples(examples map[string]any) RouteOption
- func WithResponseExamples(examples map[string]any) RouteOption
- func WithSecurity(items ...string) RouteOption
- func WithTags(tags ...string) RouteOption
- func WithVersion(version string) RouteOption
- type Router
- type SSEEvent
- type SSEWriter
- type Server
- type SortField
- type StreamResponse
- type StructValidatorFunc
- type TenantResolveFunc
- type ValidationErrors
- type WSConfig
- type WSConn
Constants ¶
This section is empty.
Variables ¶
var EnableLegacyTagSync = true
EnableLegacyTagSync controls one-time migration of legacy struct tags into typemeta.Attributes. Keeping it enabled preserves backward compatibility while bind/validate rely on typemeta only.
Functions ¶
func APIVersionFromContext ¶
APIVersionFromContext returns resolved API version.
func CacheControlHeaders ¶
CacheControlHeaders helper for response cache directives.
func ConfigureFieldMetadata ¶
func ConfigureFieldMetadata(model any, fieldGoName string, cfg FieldMetadataConfig) error
ConfigureFieldMetadata writes arc binding/validation metadata into orm.SharedTypeRegistry attributes.
func DefaultDocsHTML ¶
DefaultDocsHTML returns API docs page backed by Swagger UI CDN.
func FlattenIncludeTree ¶
func FlattenIncludeTree(tree IncludeTree) []string
FlattenIncludeTree returns sorted flat include list from tree.
func Handle ¶
func Handle[Input any, Output any](e *Engine, method, path, operationID string, h func(context.Context, *Input) (*Response[Output], error), opts ...RouteOption)
Handle registers typed handler of shape func(ctx, *Input) (*Response[Output], error).
func HandleErr ¶
func HandleErr[Input any](e *Engine, method, path, operationID string, h func(context.Context, *Input) error, opts ...RouteOption)
HandleErr registers handler of shape func(ctx, *Input) error.
func HandleGroup ¶
func HandleGroup[Input any, Output any](g *Group, method, path, operationID string, h func(context.Context, *Input) (*Response[Output], error), opts ...RouteOption)
Handle registers typed handler in group.
func HandleOut ¶
func HandleOut[Input any, Output any](e *Engine, method, path, operationID string, h func(context.Context, *Input) (*Output, error), opts ...RouteOption)
HandleOut registers handler of shape func(ctx, *Input) (*Output, error).
func HandleRawTyped ¶
func HandleRawTyped[Input any](e *Engine, method, path, operationID string, h func(context.Context, *Input) (*RawResponse, error), opts ...RouteOption)
HandleRawTyped registers handler of shape func(ctx, *Input) (*RawResponse, error).
func HandleSSE ¶
func HandleSSE[Input any](e *Engine, method, path, operationID string, h func(context.Context, *Input, *SSEWriter) error, opts ...RouteOption)
HandleSSE registers route that streams server-sent events.
func HandleStreamTyped ¶
func HandleStreamTyped[Input any](e *Engine, method, path, operationID string, h func(context.Context, *Input) (*StreamResponse, error), opts ...RouteOption)
HandleStreamTyped registers handler of shape func(ctx, *Input) (*StreamResponse, error).
func HandleWebSocket ¶
func HandleWebSocket[Input any](e *Engine, method, path, operationID string, cfg WSConfig, h func(context.Context, *Input, *WSConn) error, opts ...RouteOption)
HandleWebSocket registers websocket endpoint helper.
func HasInclude ¶
HasInclude reports whether exact include path was requested.
func IncludesFromContext ¶
IncludesFromContext returns validated include paths.
func ParseIncludes ¶
ParseIncludes parses comma-separated include and validates against allowlist.
func RegisterValidator ¶
RegisterValidator registers additional struct validator for input type T.
func TenantFromContext ¶
TenantFromContext returns tenant value.
func ValidateOpenAPIQuality ¶ added in v0.1.1
func ValidateOpenAPIQuality(spec map[string]any, gates OpenAPIQualityGates) []string
ValidateOpenAPIQuality checks generated spec against requested quality gates. It returns a list of violations; empty result means the spec passed.
func WithAPIVersion ¶
WithAPIVersion stores resolved API version in context.
func WithIncludes ¶
WithIncludes stores validated include paths in context.
func WithListQueryDTO ¶
func WithListQueryDTO(ctx context.Context, dto ListQueryDTO) context.Context
WithListQueryDTO stores parsed list query DTO in context.
Types ¶
type APIError ¶
type APIError struct {
Status int `json:"-"`
Code string `json:"code"`
Message string `json:"message"`
Details []ErrorDetail `json:"details,omitempty"`
RequestID string `json:"requestId,omitempty"`
}
APIError is standard error payload.
type APIVersionSource ¶
type APIVersionSource string
APIVersionSource identifies request source for API version extraction.
const ( APIVersionSourceHeader APIVersionSource = "header" APIVersionSourceQuery APIVersionSource = "query" APIVersionSourceAccept APIVersionSource = "accept" )
type APIVersioningConfig ¶
type APIVersioningConfig struct {
Header string
QueryParam string
AcceptParam string
Sources []APIVersionSource
DefaultVersion string
Required bool
ResponseHeader string
}
APIVersioningConfig configures API version extraction middleware.
type CacheConfig ¶
type CacheConfig struct {
TTL time.Duration
VaryHeaders []string
SkipAuthorized bool
SkipCookies bool
Store *ResponseCache
}
CacheConfig configures in-memory response cache middleware.
type CacheInvalidationConfig ¶
type CacheInvalidationConfig struct {
Store *ResponseCache
Methods []string
PathPrefixes []string
PathPrefixResolver func(*http.Request) []string
ClearOnAnyMatch bool
InvalidateRequestPath bool
}
CacheInvalidationConfig configures cache invalidation middleware.
type Encoder ¶
type Encoder interface {
Encode(w http.ResponseWriter, status int, body any) error
}
Encoder writes response payload.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is HTTP/API runtime core.
func (*Engine) AddObserver ¶
AddObserver adds request observer hooks.
func (*Engine) AddOpenAPIServer ¶ added in v0.1.1
AddOpenAPIServer appends one server entry with URL and optional description.
func (*Engine) Group ¶
func (e *Engine) Group(prefix string, middleware ...Middleware) *Group
Group creates route group.
func (*Engine) MarshalOpenAPIJSON ¶
MarshalOpenAPIJSON renders current OpenAPI spec as JSON bytes.
func (*Engine) MarshalOpenAPIYAML ¶
MarshalOpenAPIYAML renders current OpenAPI spec as YAML bytes.
func (*Engine) OpenAPISpec ¶ added in v0.1.1
OpenAPISpec returns current OpenAPI spec as map.
func (*Engine) Operations ¶
Operations returns copy of registered operations.
func (*Engine) RegisterEncoder ¶
RegisterEncoder registers encoder for specific media type.
func (*Engine) RegisterHealthRoutes ¶
func (e *Engine) RegisterHealthRoutes()
func (*Engine) RegisterOpenAPISecurityScheme ¶ added in v0.1.1
RegisterOpenAPISecurityScheme registers components.securitySchemes entry.
func (*Engine) RegisterRaw ¶
func (e *Engine) RegisterRaw(method, path, operationID string, h Handler, middleware ...Middleware)
RegisterRaw registers raw route handler.
func (*Engine) RegisterSchemaRoutes ¶
RegisterSchemaRoutes mounts JSON Schema endpoints.
func (*Engine) RegisterSystemRoutes ¶
RegisterSystemRoutes mounts openapi and docs endpoints.
func (*Engine) ServeHTTP ¶
func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Engine) SetEncoder ¶
SetEncoder overrides response encoder.
func (*Engine) SetErrorMapper ¶
func (e *Engine) SetErrorMapper(m ErrorMapper)
SetErrorMapper overrides default mapper.
func (*Engine) SetOpenAPIServers ¶ added in v0.1.1
SetOpenAPIServers configures root OpenAPI servers list.
type ErrorDetail ¶
type ErrorDetail struct {
Path string `json:"path,omitempty"`
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
}
ErrorDetail describes one validation/binding problem.
type ErrorMapper ¶
ErrorMapper converts domain/runtime errors into API error payload.
type FieldMetadataConfig ¶
type FieldMetadataConfig struct {
Path string
Query string
Header string
Cookie string
Form string
Validate string
}
FieldMetadataConfig configures arc-specific metadata for one field in shared typemeta.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group holds shared route config.
func (*Group) Group ¶
func (g *Group) Group(prefix string, middleware ...Middleware) *Group
Group creates nested group.
func (*Group) WithAcceptVersioning ¶
WithAcceptVersioning resolves API version only from Accept parameter within this group.
func (*Group) WithCallbacks ¶
WithCallbacks returns group copy with inherited OpenAPI callbacks.
func (*Group) WithHeaderVersioning ¶
WithHeaderVersioning resolves API version only from header within this group.
func (*Group) WithIncludeAllowlist ¶
WithIncludeAllowlist returns group copy with inherited include allowlist.
func (*Group) WithIncludeParamName ¶
WithIncludeParamName returns group copy with inherited include query name.
func (*Group) WithMetadata ¶
WithMetadata returns group copy with inherited operation metadata.
func (*Group) WithQueryDTO ¶
WithQueryDTO returns group copy that enables query DTO parsing.
func (*Group) WithQueryVersioning ¶
WithQueryVersioning resolves API version only from query param within this group.
func (*Group) WithSecurity ¶
WithSecurity returns group copy with inherited security schemes.
func (*Group) WithVersion ¶
WithVersion returns group copy with inherited API version marker.
func (*Group) WithVersioning ¶
func (g *Group) WithVersioning(cfg APIVersioningConfig) *Group
WithVersioning returns group copy with API version extraction middleware.
type HMACJWTVerifier ¶
type HMACJWTVerifier struct {
// contains filtered or unexported fields
}
HMACJWTVerifier verifies JWT with HMAC SHA algorithms.
func NewHMACJWTVerifier ¶
func NewHMACJWTVerifier(secret []byte, allowedAlgs ...string) *HMACJWTVerifier
NewHMACJWTVerifier creates HMAC JWT verifier for HS256/HS384/HS512.
func (*HMACJWTVerifier) VerifyAndParse ¶
func (v *HMACJWTVerifier) VerifyAndParse(token string) (map[string]any, error)
VerifyAndParse verifies JWT signature and temporal claims.
func (*HMACJWTVerifier) WithLeeway ¶
func (v *HMACJWTVerifier) WithLeeway(d time.Duration) *HMACJWTVerifier
WithLeeway configures allowed clock skew for exp/nbf/iat checks.
type IncludeTree ¶
type IncludeTree map[string]IncludeTree
IncludeTree represents nested include graph: profile, roles.permissions, ...
func BuildIncludeTree ¶
func BuildIncludeTree(includes []string) IncludeTree
BuildIncludeTree builds nested relation tree from flat include paths.
func IncludeTreeFromContext ¶
func IncludeTreeFromContext(ctx context.Context) IncludeTree
IncludeTreeFromContext returns nested relation tree from includes in context.
type JSONEncoder ¶
type JSONEncoder struct{}
JSONEncoder writes JSON payloads.
func (JSONEncoder) Encode ¶
func (JSONEncoder) Encode(w http.ResponseWriter, status int, body any) error
type JWTVerifier ¶
JWTVerifier verifies JWT signature and temporal claims.
type ListQueryDTO ¶
type ListQueryDTO struct {
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
Sort []SortField `json:"sort,omitempty"`
Include []string `json:"include,omitempty"`
Filters map[string][]string `json:"filters,omitempty"`
}
ListQueryDTO contains normalized list-query primitives.
func QueryDTOFromContext ¶
func QueryDTOFromContext(ctx context.Context) (ListQueryDTO, bool)
QueryDTOFromContext returns parsed list query DTO.
type Middleware ¶
Middleware wraps route handler.
func APIVersioning ¶
func APIVersioning(cfg APIVersioningConfig) Middleware
APIVersioning resolves API version from request metadata and injects it into context.
func CacheResponses ¶
func CacheResponses(ttl time.Duration) Middleware
CacheResponses caches GET/HEAD responses in-memory for ttl.
func CacheResponsesWithConfig ¶
func CacheResponsesWithConfig(cfg CacheConfig) Middleware
CacheResponsesWithConfig caches responses using explicit cache configuration.
func InvalidateCacheOnWrite ¶
func InvalidateCacheOnWrite(cfg CacheInvalidationConfig) Middleware
InvalidateCacheOnWrite clears/invalidate cache entries after mutating requests.
func TenantExtractor ¶
func TenantExtractor(extractors ...TenantResolveFunc) Middleware
TenantExtractor reads tenant from request and injects into context.
type Observer ¶
type Observer interface {
OnRequestStart(*RequestContext)
OnRequestEnd(*RequestContext, int, error, time.Duration)
}
Observer receives request lifecycle events for logging/metrics/tracing.
type ObserverFunc ¶
type ObserverFunc struct {
Start func(*RequestContext)
End func(*RequestContext, int, error, time.Duration)
}
ObserverFunc allows plugging simple callbacks.
func (ObserverFunc) OnRequestEnd ¶
func (o ObserverFunc) OnRequestEnd(rc *RequestContext, status int, err error, d time.Duration)
func (ObserverFunc) OnRequestStart ¶
func (o ObserverFunc) OnRequestStart(rc *RequestContext)
type OpenAPIQualityGates ¶ added in v0.1.1
type OpenAPIQualityGates struct {
RequireRootTags bool
RequireServers bool
RequireExamples bool
RequiredSecuritySchemes []string
}
OpenAPIQualityGates configures required quality constraints for generated OpenAPI.
type Operation ¶
type Operation struct {
Method string
Path string
OperationID string
Handler Handler
Middleware []Middleware
Metadata map[string]string
Version string
Callbacks map[string]any
InputType any
OutputType any
Tags []string
Security []string
MiddlewareN int
Params []OperationParam
HasRequestBody bool
HasFormBody bool
InputContentType string
ResponseKind responseKind
IncludeAllowlist []string
IncludeParamName string
HasQueryDTO bool
RequestExamples map[string]any
ResponseExamples map[string]any
ProblemStatuses []int
ProblemExamples map[int]map[string]any
}
Operation describes registered endpoint.
type OperationParam ¶
OperationParam describes one OpenAPI operation parameter.
type OperationRegistry ¶
type OperationRegistry struct {
// contains filtered or unexported fields
}
OperationRegistry stores all operations.
func NewOperationRegistry ¶
func NewOperationRegistry() *OperationRegistry
func (*OperationRegistry) Add ¶
func (r *OperationRegistry) Add(op Operation)
func (*OperationRegistry) JSONSchemaForType ¶
func (r *OperationRegistry) JSONSchemaForType(model any) map[string]any
JSONSchemaForType generates JSON Schema for one Go type.
func (*OperationRegistry) JSONSchemas ¶
func (r *OperationRegistry) JSONSchemas() map[string]any
JSONSchemas returns generated component schemas from registered operations.
func (*OperationRegistry) List ¶
func (r *OperationRegistry) List() []Operation
func (*OperationRegistry) MarshalJSONSchemasJSON ¶
func (r *OperationRegistry) MarshalJSONSchemasJSON() ([]byte, error)
MarshalJSONSchemasJSON renders all generated schemas as JSON bytes.
func (*OperationRegistry) MarshalOpenAPIJSON ¶
func (r *OperationRegistry) MarshalOpenAPIJSON() ([]byte, error)
MarshalOpenAPIJSON renders OpenAPI spec as JSON bytes.
func (*OperationRegistry) MarshalOpenAPIYAML ¶
func (r *OperationRegistry) MarshalOpenAPIYAML() ([]byte, error)
MarshalOpenAPIYAML renders OpenAPI spec as YAML bytes.
func (*OperationRegistry) OpenAPISpec ¶
func (r *OperationRegistry) OpenAPISpec() map[string]any
func (*OperationRegistry) RegisterSecurityScheme ¶ added in v0.1.1
func (r *OperationRegistry) RegisterSecurityScheme(name string, scheme map[string]any)
RegisterSecurityScheme registers OpenAPI security scheme in components.
func (*OperationRegistry) SetServers ¶ added in v0.1.1
func (r *OperationRegistry) SetServers(servers []map[string]any)
SetServers configures root OpenAPI servers list.
func (*OperationRegistry) Update ¶
func (r *OperationRegistry) Update(method, path, operationID string, fn func(*Operation))
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional stores tri-state field state for PATCH DTOs: absent, explicit null, explicit value.
func (Optional[T]) MarshalJSON ¶
MarshalJSON encodes absent/null as null and explicit value as JSON value.
func (Optional[T]) OptionalIsNull ¶
OptionalIsNull exposes null state for validation internals.
func (Optional[T]) OptionalIsSet ¶
OptionalIsSet exposes set state for validation internals.
func (Optional[T]) OptionalValueAny ¶
OptionalValueAny returns underlying value for validation internals.
func (*Optional[T]) UnmarshalJSON ¶
UnmarshalJSON tracks absent/null/value state.
func (*Optional[T]) UnmarshalText ¶
UnmarshalText supports binding from query/header/cookie/form.
type OptionalBool ¶
OptionalBool is convenience alias for Optional[bool].
type OptionalInt ¶
OptionalInt is convenience alias for Optional[int].
type OptionalString ¶
OptionalString is convenience alias for Optional[string].
type ProblemExampleSpec ¶ added in v0.1.1
ProblemExampleSpec describes one problem+json response example.
type RawResponse ¶
RawResponse allows writing arbitrary response formats.
type RequestContext ¶
type RequestContext struct {
Writer http.ResponseWriter
Request *http.Request
Params map[string]string
Engine *Engine
Ctx context.Context
}
RequestContext carries request-scoped values.
type Response ¶
Response is typed HTTP response envelope.
type ResponseCache ¶
type ResponseCache struct {
// contains filtered or unexported fields
}
ResponseCache stores cached HTTP responses.
func NewResponseCache ¶
func NewResponseCache() *ResponseCache
NewResponseCache creates empty cache store.
func (*ResponseCache) InvalidatePathPrefix ¶
func (c *ResponseCache) InvalidatePathPrefix(prefix string)
InvalidatePathPrefix removes cached entries where request path starts with prefix.
type Route ¶
type Route struct {
Handler Handler
Middleware []Middleware
}
Route describes runtime route entry.
type RouteOption ¶
type RouteOption func(*routeConfig)
RouteOption configures operation metadata.
func WithCallbacks ¶
func WithCallbacks(callbacks map[string]any) RouteOption
WithCallbacks attaches OpenAPI callbacks object for the route.
func WithIncludeAllowlist ¶
func WithIncludeAllowlist(paths ...string) RouteOption
WithIncludeAllowlist enables relation include parsing and validation.
func WithIncludeParamName ¶
func WithIncludeParamName(name string) RouteOption
WithIncludeParamName overrides include query parameter name (default: include).
func WithMetadata ¶
func WithMetadata(items map[string]string) RouteOption
WithMetadata attaches operation metadata.
func WithMiddleware ¶
func WithMiddleware(mw ...Middleware) RouteOption
WithMiddleware attaches route middleware.
func WithProblemResponseSpec ¶ added in v0.1.1
func WithProblemResponseSpec(spec map[int]ProblemExampleSpec) RouteOption
WithProblemResponseSpec registers explicit problem+json responses with examples.
func WithProblemResponses ¶ added in v0.1.1
func WithProblemResponses(statuses ...int) RouteOption
WithProblemResponses registers explicit problem+json responses for status codes.
func WithQueryDTO ¶
func WithQueryDTO() RouteOption
WithQueryDTO enables parsing list query DTO from URL params.
func WithRequestExamples ¶ added in v0.1.1
func WithRequestExamples(examples map[string]any) RouteOption
WithRequestExamples attaches OpenAPI request body examples for operation input content type.
func WithResponseExamples ¶ added in v0.1.1
func WithResponseExamples(examples map[string]any) RouteOption
WithResponseExamples attaches OpenAPI 200 application/json examples.
func WithSecurity ¶
func WithSecurity(items ...string) RouteOption
WithSecurity marks security schemes.
func WithVersion ¶
func WithVersion(version string) RouteOption
WithVersion marks API version for route metadata/OpenAPI extension.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is radix-like route tree per method.
func (*Router) AllowedMethods ¶
AllowedMethods returns methods matching the same path pattern.
type SSEWriter ¶
type SSEWriter struct {
// contains filtered or unexported fields
}
SSEWriter writes SSE events to response stream.
func NewSSEWriter ¶
func NewSSEWriter(w http.ResponseWriter) (*SSEWriter, error)
NewSSEWriter prepares SSE response headers.
func (*SSEWriter) WriteEvent ¶
WriteEvent sends one SSE frame.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps http.Server lifecycle helpers.
type StreamResponse ¶
StreamResponse describes streaming body response.
type StructValidatorFunc ¶
StructValidatorFunc validates one input struct instance.
type TenantResolveFunc ¶
type TenantResolveFunc func(*RequestContext) (string, bool)
TenantResolveFunc extracts tenant id from request context.
func TenantFromCookie ¶
func TenantFromCookie(name string) TenantResolveFunc
func TenantFromHeader ¶
func TenantFromHeader(name string) TenantResolveFunc
func TenantFromJWTClaim ¶
func TenantFromJWTClaim(claim string) TenantResolveFunc
TenantFromJWTClaim extracts tenant from Bearer JWT payload claim. It only decodes JWT payload and does not verify signature.
func TenantFromPath ¶
func TenantFromPath(param string) TenantResolveFunc
func TenantFromVerifiedJWTClaim ¶
func TenantFromVerifiedJWTClaim(claim string, verifier JWTVerifier) TenantResolveFunc
TenantFromVerifiedJWTClaim extracts tenant from verified JWT claim.
type ValidationErrors ¶
type ValidationErrors struct {
Details []ErrorDetail
}
ValidationErrors collects multiple input violations.
func (*ValidationErrors) Error ¶
func (e *ValidationErrors) Error() string