Versions in this module Expand all Collapse all v2 v2.0.1 Jul 25, 2026 v2.0.0 Jul 25, 2026 Changes in this version + const RateLimitDecisionKey + const ValidationRuleEnum + const ValidationRuleMax + const ValidationRuleMaxLength + const ValidationRuleMin + const ValidationRuleMinLength + const ValidationRulePattern + const ValidationRuleRequired + func BindRequest[Req any](ctx *Context, config BindConfig[Req]) (Req, error) + func CacheControlISR(revalidateSeconds, staleWhileRevalidateSeconds int) string + func CacheControlSSG() string + func CacheControlSSR() string + func CaptureBodyStream(ctx context.Context, stream BodyStream) ([][]byte, []byte, error) + func ClientIP(headers map[string][]string) string + func ETag(body []byte) string + func GenerateOpenAPI(spec OpenAPISpec) (map[string]any, error) + func GenerateOpenAPIJSON(spec OpenAPISpec) ([]byte, error) + func IsLambda() bool + func MatchesIfNoneMatch(headers map[string][]string, etag string) bool + func OriginURL(headers map[string][]string) string + func OriginalHost(headers map[string][]string) string + func OriginalURI(headers map[string][]string) string + func SafeJSONForHTML(value any) (string, error) + func StepFunctionsTaskToken(event any) string + func Vary(existing []string, add ...string) []string + type App struct + func New(opts ...Option) *App + func (a *App) Delete(pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) DeleteStrict(pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) DynamoDB(tableName string, handler DynamoDBStreamHandler) *App + func (a *App) EventBridge(selector EventBridgeSelector, handler EventBridgeHandler) *App + func (a *App) Get(pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) GetStrict(pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) Handle(method, pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) HandleLambda(ctx context.Context, event json.RawMessage) (any, error) + func (a *App) HandleStrict(method, pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) IsLambda() bool + func (a *App) Kinesis(streamName string, handler KinesisHandler) *App + func (a *App) Options(pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) OptionsStrict(pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) Patch(pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) PatchStrict(pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) Post(pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) PostStrict(pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) Put(pattern string, handler Handler, opts ...RouteOption) *App + func (a *App) PutStrict(pattern string, handler Handler, opts ...RouteOption) (*App, error) + func (a *App) SNS(topicName string, handler SNSHandler) *App + func (a *App) SQS(queueName string, handler SQSHandler) *App + func (a *App) Serve(ctx context.Context, req Request) (resp Response) + func (a *App) ServeALB(ctx context.Context, event events.ALBTargetGroupRequest) events.ALBTargetGroupResponse + func (a *App) ServeAPIGatewayProxy(ctx context.Context, event events.APIGatewayProxyRequest) events.APIGatewayProxyResponse + func (a *App) ServeAPIGatewayV2(ctx context.Context, event events.APIGatewayV2HTTPRequest) events.APIGatewayV2HTTPResponse + func (a *App) ServeAppSync(ctx context.Context, event AppSyncResolverEvent) any + func (a *App) ServeDynamoDBStream(ctx context.Context, event events.DynamoDBEvent) events.DynamoDBEventResponse + func (a *App) ServeEventBridge(ctx context.Context, event events.EventBridgeEvent) (any, error) + func (a *App) ServeKinesis(ctx context.Context, event events.KinesisEvent) events.KinesisEventResponse + func (a *App) ServeLambdaFunctionURL(ctx context.Context, event events.LambdaFunctionURLRequest) events.LambdaFunctionURLResponse + func (a *App) ServeSNS(ctx context.Context, event events.SNSEvent) ([]any, error) + func (a *App) ServeSQS(ctx context.Context, event events.SQSEvent) events.SQSEventResponse + func (a *App) ServeWebSocket(ctx context.Context, event events.APIGatewayWebsocketProxyRequest) (proxy events.APIGatewayProxyResponse) + func (a *App) Use(mw Middleware) *App + func (a *App) UseEvents(mw EventMiddleware) *App + func (a *App) WebSocket(routeKey string, handler WebSocketHandler) *App + type AppError struct + Code string + Message string + func (e *AppError) Error() string + type AppSyncContext struct + Arguments map[string]any + FieldName string + Identity map[string]any + ParentTypeName string + Prev any + RawEvent AppSyncResolverEvent + RequestHeaders map[string]string + Source map[string]any + Stash map[string]any + Variables map[string]any + type AppSyncResolverEvent struct + Arguments map[string]any + Identity map[string]any + Info AppSyncResolverInfo + Prev any + Request AppSyncResolverRequest + Source map[string]any + Stash map[string]any + type AppSyncResolverInfo struct + FieldName string + ParentTypeName string + SelectionSetGraphQL string + SelectionSetList []string + Variables map[string]any + type AppSyncResolverRequest struct + Headers map[string]string + type AppTheoryError struct + Cause error + Code string + Details map[string]any + Message string + RequestID string + StackTrace string + StatusCode int + Timestamp time.Time + TraceID string + func AppTheoryErrorFromAppError(err *AppError) *AppTheoryError + func AsAppTheoryError(err error) (*AppTheoryError, bool) + func NewAppTheoryError(code, message string) *AppTheoryError + func (e *AppTheoryError) Error() string + func (e *AppTheoryError) Unwrap() error + func (e *AppTheoryError) WithCause(err error) *AppTheoryError + func (e *AppTheoryError) WithDetails(details map[string]any) *AppTheoryError + func (e *AppTheoryError) WithRequestID(requestID string) *AppTheoryError + func (e *AppTheoryError) WithStackTrace(stackTrace string) *AppTheoryError + func (e *AppTheoryError) WithStatusCode(statusCode int) *AppTheoryError + func (e *AppTheoryError) WithTimestamp(timestamp time.Time) *AppTheoryError + func (e *AppTheoryError) WithTraceID(traceID string) *AppTheoryError + type AuthHook func(*Context) (identity string, err error) + type AuthPrincipal struct + Claims map[string]any + Identity string + Scopes []string + type BindConfig struct + Body bool + Headers bool + Path bool + Query bool + StrictJSON bool + SuccessStatus int + Validate func(*Context, Req) error + type BodyStream <-chan StreamChunk + func StreamBytes(chunks ...[]byte) BodyStream + func StreamError(err error) BodyStream + type CORSConfig struct + AllowCredentials bool + AllowHeaders []string + AllowedOrigins []string + type Clock interface + Now func() time.Time + type CloudWatchLogsSubscription struct + LogEvents []CloudWatchLogsSubscriptionLogEvent + LogGroup string + LogStream string + MessageType string + Owner string + RecordID string + SafeSummary CloudWatchLogsSubscriptionSummary + SubscriptionFilters []string + func DecodeCloudWatchLogsSubscription(record events.KinesisEventRecord) (CloudWatchLogsSubscription, error) + type CloudWatchLogsSubscriptionLogEvent struct + ID string + Message string + Timestamp int64 + type CloudWatchLogsSubscriptionSummary struct + LogEventCount int + LogGroup string + LogStream string + MessageType string + Owner string + RecordID string + SafeLog string + SubscriptionFilterCount int + type Context struct + AuthIdentity string + AuthPrincipal *AuthPrincipal + MiddlewareTrace []string + Params map[string]string + RemainingMS int + Request Request + RequestID string + TenantID string + TraceID string + func (c *Context) AsAppSync() *AppSyncContext + func (c *Context) AsWebSocket() *WebSocketContext + func (c *Context) Context() context.Context + func (c *Context) Get(key string) any + func (c *Context) Header(name string) string + func (c *Context) JSONValue() (any, error) + func (c *Context) NewID() string + func (c *Context) Now() time.Time + func (c *Context) Param(name string) string + func (c *Context) Query(name string) string + func (c *Context) QueryAll(name string) []string + func (c *Context) Set(key string, value any) + func (c *Context) SourceIP() string + func (c *Context) SourceProvenance() SourceProvenance + func (c *Context) TraceContextID() string + type DynamoDBStreamHandler func(*EventContext, events.DynamoDBEventRecord) error + type DynamoDBStreamRecordSummary struct + AWSRegion string + EventID string + EventName string + SafeLog string + SequenceNumber string + SizeBytes int64 + StreamViewType string + TableName string + func NormalizeDynamoDBStreamRecord(record events.DynamoDBEventRecord) DynamoDBStreamRecordSummary + type EventBridgeHandler func(*EventContext, events.EventBridgeEvent) (any, error) + type EventBridgeScheduledWorkloadResultSummary struct + Failed int + Processed int + Status string + type EventBridgeScheduledWorkloadSummary struct + CorrelationID string + CorrelationSource string + DeadlineUnixMS int64 + DetailType string + EventID string + IdempotencyKey string + Kind string + RemainingMS int + Result EventBridgeScheduledWorkloadResultSummary + RunID string + ScheduledTime string + Source string + func NormalizeEventBridgeScheduledWorkload(ctx *EventContext, event events.EventBridgeEvent) EventBridgeScheduledWorkloadSummary + type EventBridgeSelector struct + DetailType string + RuleName string + Source string + func EventBridgePattern(source, detailType string) EventBridgeSelector + func EventBridgeRule(ruleName string) EventBridgeSelector + type EventBridgeWorkloadEnvelope struct + Account string + CorrelationID string + CorrelationSource string + DetailType string + EventID string + Region string + RequestID string + Resources []string + Source string + Time string + func NormalizeEventBridgeWorkloadEnvelope(ctx *EventContext, event events.EventBridgeEvent) EventBridgeWorkloadEnvelope + func RequireEventBridgeWorkloadEnvelope(ctx *EventContext, event events.EventBridgeEvent) (EventBridgeWorkloadEnvelope, error) + type EventContext struct + RemainingMS int + RequestID string + func (c *EventContext) Context() context.Context + func (c *EventContext) Get(key string) any + func (c *EventContext) NewID() string + func (c *EventContext) Now() time.Time + func (c *EventContext) Set(key string, value any) + type EventHandler func(*EventContext, any) (any, error) + type EventMiddleware func(EventHandler) EventHandler + type HTTPErrorFormat string + const HTTPErrorFormatFlatLegacy + const HTTPErrorFormatNested + type Handler func(*Context) (*Response, error) + func BindHandlerContext[Req, Resp any](config BindConfig[Req], handler func(context.Context, Req) (Resp, error)) Handler + func BindHandler[Req, Resp any](config BindConfig[Req], handler func(*Context, Req) (Resp, error)) Handler + func JSONHandlerContext[Req, Resp any](handler func(context.Context, Req) (Resp, error)) Handler + func JSONHandler[Req, Resp any](handler func(*Context, Req) (Resp, error)) Handler + type IDGenerator interface + NewID func() string + type IdGenerator = IDGenerator + type KinesisHandler func(*EventContext, events.KinesisEventRecord) error + type KinesisJSONRecord struct + Data []byte + ExplicitHashKey string + PartitionKey string + SafeSummary KinesisJSONRecordSummary + func NewKinesisJSONRecord(opts KinesisJSONRecordOptions) (KinesisJSONRecord, error) + type KinesisJSONRecordOptions struct + ExplicitHashKey string + PartitionKey string + Payload any + type KinesisJSONRecordSummary struct + DataByteLength int + ExplicitHashKey string + PartitionKey string + SafeLog string + type KinesisPutRecordsFailure struct + DataByteLength int + ErrorCode string + ErrorMessageByteLength int + ErrorMessagePresent bool + ExplicitHashKey string + Index int + PartitionKey string + SafeLog string + type KinesisPutRecordsFailureReport struct + FailedRecordCount int + Failures []KinesisPutRecordsFailure + RecordCount int + SafeSummary KinesisPutRecordsFailureReportSummary + func ReportKinesisPutRecordsFailures(records []KinesisJSONRecord, results []KinesisPutRecordsResultRecord) (KinesisPutRecordsFailureReport, error) + type KinesisPutRecordsFailureReportSummary struct + FailedRecordCount int + RecordCount int + SafeLog string + type KinesisPutRecordsResultRecord struct + ErrorCode string + ErrorMessage string + SequenceNumber string + ShardID string + type Limits struct + MaxRequestBytes int + MaxResponseBytes int + type LogRecord struct + CorrelationID string + DetailType string + DurationMS int + ErrorCode string + Event string + EventID string + EventName string + Level string + Method string + Path string + RequestID string + Source string + Status int + TableName string + TenantID string + TraceID string + Trigger string + type MetricRecord struct + DurationMS int + Name string + Tags map[string]string + Value int + type Middleware func(Handler) Handler + func RateLimitMiddleware(config RateLimitConfig) Middleware + func TimeoutMiddleware(config TimeoutConfig) Middleware + type ObservabilityHooks struct + Log func(LogRecord) + Metric func(MetricRecord) + Span func(SpanRecord) + type OpenAPIFieldSpec struct + Array bool + Field string + Name string + Required bool + Source string + Type string + Validation []OpenAPIValidationRule + type OpenAPIRequestSpec struct + Fields []OpenAPIFieldSpec + type OpenAPIResponseSpec struct + Description string + Fields []OpenAPIFieldSpec + type OpenAPIRouteSpec struct + Method string + OperationID string + Path string + Request OpenAPIRequestSpec + Response OpenAPIResponseSpec + SuccessStatus *int + Summary string + Tags []string + type OpenAPISpec struct + Routes []OpenAPIRouteSpec + Title string + Version string + type OpenAPIValidationRule struct + Rule string + Value any + type Option func(*App) + func WithAuthHook(hook AuthHook) Option + func WithAuthPrincipalHook(hook PrincipalAuthHook) Option + func WithCORS(config CORSConfig) Option + func WithClock(clock Clock) Option + func WithHTTPErrorFormat(format HTTPErrorFormat) Option + func WithIDGenerator(ids IDGenerator) Option + func WithLegacyHTTPErrorShape() Option + func WithLimits(limits Limits) Option + func WithObservability(hooks ObservabilityHooks) Option + func WithPolicyHook(hook PolicyHook) Option + func WithTier(tier Tier) Option + func WithWebSocketClientFactory(factory WebSocketClientFactory) Option + func WithWebSocketSupport() Option + type PolicyDecision struct + Code string + Headers map[string][]string + Message string + type PolicyHook func(*Context) (*PolicyDecision, error) + type PrincipalAuthHook func(*Context) (*AuthPrincipal, error) + type RandomIDGenerator struct + func (RandomIDGenerator) NewID() string + type RandomIdGenerator = RandomIDGenerator + type RateLimitConfig struct + ExtractIdentifier func(ctx *Context) string + ExtractOperation func(ctx *Context) string + ExtractResource func(ctx *Context) string + FailClosed bool + Limiter limited.RateLimiter + OnError func(ctx *Context, err error) + OnRateLimit func(ctx *Context, decision *limited.LimitDecision) + OnSuccess func(ctx *Context, decision *limited.LimitDecision) + type RealClock struct + func (RealClock) Now() time.Time + type Request struct + Body []byte + Cookies map[string]string + Headers map[string][]string + IsBase64 bool + Method string + Path string + Query map[string][]string + SourceProvenance SourceProvenance + TraceID string + type Response struct + Body []byte + BodyReader io.Reader + BodyStream BodyStream + Cookies []string + Headers map[string][]string + IsBase64 bool + Status int + func Binary(status int, body []byte, contentType string) *Response + func CreatedJSON(value any) (*Response, error) + func HTML(status int, body any) *Response + func HTMLStream(status int, stream BodyStream) *Response + func JSON(status int, value any) (*Response, error) + func MustJSON(status int, value any) *Response + func MustSSEResponse(status int, events ...SSEEvent) *Response + func NoContent() *Response + func SSEResponse(status int, events ...SSEEvent) (*Response, error) + func SSEStreamResponse(ctx context.Context, status int, events <-chan SSEEvent) (*Response, error) + func Text(status int, body string) *Response + func (r *Response) SetHeader(name string, value string) *Response + type RouteOption func(*routeOptions) + func OptionalAuth() RouteOption + func RequireAnyScope(scopes ...string) RouteOption + func RequireAuth() RouteOption + func RequireScope(scopes ...string) RouteOption + type SNSHandler func(*EventContext, events.SNSEventRecord) (any, error) + type SQSHandler func(*EventContext, events.SQSMessage) error + type SSEEvent struct + Data any + Event string + ID string + type SourceProvenance struct + Provider string + Source string + SourceIP string + Valid bool + type SpanRecord struct + Attributes map[string]string + Name string + type StreamChunk struct + Bytes []byte + Err error + type Tier string + const TierP0 + const TierP1 + const TierP2 + type TimeoutConfig struct + DefaultTimeout time.Duration + OperationTimeouts map[string]time.Duration + TenantTimeouts map[string]time.Duration + TimeoutMessage string + type ValidationFieldError struct + Field string + Message string + Rule string + type WebSocketClientFactory func(context.Context, string) (streamer.Client, error) + type WebSocketContext struct + Body []byte + ConnectionID string + DomainName string + EventType string + ManagementEndpoint string + RemainingMS int + RequestID string + RouteKey string + Stage string + func (c *WebSocketContext) Context() context.Context + func (c *WebSocketContext) NewID() string + func (c *WebSocketContext) Now() time.Time + func (c *WebSocketContext) SendJSONMessage(value any) error + func (c *WebSocketContext) SendMessage(data []byte) error + type WebSocketHandler func(*Context) (*Response, error) Other modules containing this package github.com/theory-cloud/apptheory