Documentation
¶
Index ¶
- type App
- func (a *App) Delete(pattern string, handler Handler, opts ...RouteOption) *App
- 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) Handle(method, pattern string, handler Handler, opts ...RouteOption) *App
- func (a *App) HandleLambda(ctx context.Context, event json.RawMessage) (any, error)
- func (a *App) Post(pattern string, handler Handler, opts ...RouteOption) *App
- func (a *App) Put(pattern string, handler Handler, opts ...RouteOption) *App
- func (a *App) SQS(queueName string, handler SQSHandler) *App
- func (a *App) Serve(ctx context.Context, req Request) (resp Response)
- 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) ServeDynamoDBStream(ctx context.Context, event events.DynamoDBEvent) events.DynamoDBEventResponse
- func (a *App) ServeEventBridge(ctx context.Context, event events.EventBridgeEvent) (any, error)
- func (a *App) ServeLambdaFunctionURL(ctx context.Context, event events.LambdaFunctionURLRequest) events.LambdaFunctionURLResponse
- func (a *App) ServeSQS(ctx context.Context, event events.SQSEvent) events.SQSEventResponse
- func (a *App) ServeWebSocket(ctx context.Context, event events.APIGatewayWebsocketProxyRequest) events.APIGatewayProxyResponse
- func (a *App) WebSocket(routeKey string, handler WebSocketHandler) *App
- type AppError
- type AuthHook
- type Clock
- type Context
- type DynamoDBStreamHandler
- type EventBridgeHandler
- type EventBridgeSelector
- type EventContext
- type Handler
- type IDGenerator
- type Limits
- type LogRecord
- type MetricRecord
- type ObservabilityHooks
- type Option
- func WithAuthHook(hook AuthHook) Option
- func WithClock(clock Clock) Option
- func WithIDGenerator(ids IDGenerator) 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
- type PolicyHook
- type RandomIDGenerator
- type RealClock
- type Request
- type Response
- func Binary(status int, body []byte, contentType string) *Response
- func JSON(status int, value any) (*Response, error)
- func MustJSON(status int, value any) *Response
- func MustSSEResponse(status int, events ...SSEEvent) *Response
- func SSEResponse(status int, events ...SSEEvent) (*Response, error)
- func Text(status int, body string) *Response
- type RouteOption
- type SQSHandler
- type SSEEvent
- type SpanRecord
- type Tier
- type WebSocketClientFactory
- type WebSocketContext
- type WebSocketHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the root container for an AppTheory application.
AppTheory's runtime behavior is defined by a fixture-backed, versioned contract: `docs/development/planning/apptheory/supporting/apptheory-runtime-contract-v0.md`.
func (*App) Delete ¶
func (a *App) Delete(pattern string, handler Handler, opts ...RouteOption) *App
func (*App) DynamoDB ¶
func (a *App) DynamoDB(tableName string, handler DynamoDBStreamHandler) *App
DynamoDB registers a DynamoDB Streams handler by table name.
func (*App) EventBridge ¶
func (a *App) EventBridge(selector EventBridgeSelector, handler EventBridgeHandler) *App
EventBridge registers an EventBridge handler.
Matching rules: - If selector.RuleName is set, it matches when any event resource ARN refers to that rule name. - Otherwise, it matches on selector.Source + selector.DetailType (when provided).
func (*App) Handle ¶
func (a *App) Handle(method, pattern string, handler Handler, opts ...RouteOption) *App
func (*App) HandleLambda ¶
HandleLambda routes an untyped Lambda event to the correct AppTheory entrypoint.
Supported triggers: - API Gateway v2 (HTTP API) - API Gateway REST API v1 (Proxy) - Lambda Function URL - SQS - EventBridge - DynamoDB Streams - API Gateway v2 (WebSocket API)
func (*App) SQS ¶
func (a *App) SQS(queueName string, handler SQSHandler) *App
SQS registers a handler for an SQS queue by queue name.
func (*App) ServeAPIGatewayProxy ¶
func (a *App) ServeAPIGatewayProxy(ctx context.Context, event events.APIGatewayProxyRequest) events.APIGatewayProxyResponse
func (*App) ServeAPIGatewayV2 ¶
func (a *App) ServeAPIGatewayV2(ctx context.Context, event events.APIGatewayV2HTTPRequest) events.APIGatewayV2HTTPResponse
func (*App) ServeDynamoDBStream ¶
func (a *App) ServeDynamoDBStream(ctx context.Context, event events.DynamoDBEvent) events.DynamoDBEventResponse
ServeDynamoDBStream routes a DynamoDB Streams event to the registered table handler and returns a partial batch failure response.
If the table is unrecognized, it fails closed by returning all records as failures.
func (*App) ServeEventBridge ¶
ServeEventBridge routes an EventBridge event to the first matching handler.
If no handler matches, it returns (nil, nil).
func (*App) ServeLambdaFunctionURL ¶
func (a *App) ServeLambdaFunctionURL(ctx context.Context, event events.LambdaFunctionURLRequest) events.LambdaFunctionURLResponse
func (*App) ServeSQS ¶
ServeSQS routes an SQS event to the registered queue handler and returns a partial batch failure response.
If the queue is unrecognized, it fails closed by returning all messages as failures.
func (*App) ServeWebSocket ¶
func (a *App) ServeWebSocket(ctx context.Context, event events.APIGatewayWebsocketProxyRequest) events.APIGatewayProxyResponse
type Context ¶
type Context struct {
Request Request
Params map[string]string
RequestID string
TenantID string
AuthIdentity string
RemainingMS int
MiddlewareTrace []string
// contains filtered or unexported fields
}
Context is the per-request context passed to handlers.
func (*Context) AsWebSocket ¶
func (c *Context) AsWebSocket() *WebSocketContext
type DynamoDBStreamHandler ¶
type DynamoDBStreamHandler func(*EventContext, events.DynamoDBEventRecord) error
type EventBridgeHandler ¶
type EventBridgeHandler func(*EventContext, events.EventBridgeEvent) (any, error)
type EventBridgeSelector ¶
func EventBridgePattern ¶
func EventBridgePattern(source, detailType string) EventBridgeSelector
func EventBridgeRule ¶
func EventBridgeRule(ruleName string) EventBridgeSelector
type EventContext ¶
type EventContext struct {
RequestID string
RemainingMS int
// contains filtered or unexported fields
}
EventContext is the shared context for non-HTTP Lambda triggers (SQS, EventBridge, DynamoDB Streams).
func (*EventContext) Context ¶
func (c *EventContext) Context() context.Context
func (*EventContext) NewID ¶
func (c *EventContext) NewID() string
func (*EventContext) Now ¶
func (c *EventContext) Now() time.Time
type IDGenerator ¶
type IDGenerator interface {
NewID() string
}
IDGenerator provides randomness for IDs/correlation IDs.
type ObservabilityHooks ¶
type ObservabilityHooks struct {
Log func(LogRecord)
Metric func(MetricRecord)
Span func(SpanRecord)
}
type Option ¶
type Option func(*App)
func WithAuthHook ¶
func WithIDGenerator ¶
func WithIDGenerator(ids IDGenerator) Option
func WithLimits ¶
func WithObservability ¶
func WithObservability(hooks ObservabilityHooks) Option
func WithPolicyHook ¶
func WithPolicyHook(hook PolicyHook) Option
func WithWebSocketClientFactory ¶
func WithWebSocketClientFactory(factory WebSocketClientFactory) Option
func WithWebSocketSupport ¶
func WithWebSocketSupport() Option
type PolicyDecision ¶
type PolicyHook ¶
type PolicyHook func(*Context) (*PolicyDecision, error)
type RandomIDGenerator ¶
type RandomIDGenerator struct{}
RandomIDGenerator generates IDs using cryptographic randomness.
func (RandomIDGenerator) NewID ¶
func (RandomIDGenerator) NewID() string
type Request ¶
type Request struct {
Method string
Path string
Query map[string][]string
Headers map[string][]string
Cookies map[string]string
Body []byte
IsBase64 bool
}
Request is the canonical HTTP request model used by the AppTheory runtime.
type Response ¶
type Response struct {
Status int
Headers map[string][]string
Cookies []string
Body []byte
IsBase64 bool
}
Response is the canonical HTTP response model returned by AppTheory handlers.
func MustSSEResponse ¶
MustSSEResponse builds an SSE response and panics on framing/serialization errors.
func SSEResponse ¶
SSEResponse builds a canonical AppTheory Response with properly framed SSE output.
type RouteOption ¶
type RouteOption func(*routeOptions)
func RequireAuth ¶
func RequireAuth() RouteOption
type SQSHandler ¶
type SQSHandler func(*EventContext, events.SQSMessage) error
type SSEEvent ¶
SSEEvent is a Server-Sent Events (SSE) message.
Framing rules: - Optional: "id: <id>\n" - Optional: "event: <event>\n" - Data: one "data: <line>\n" per line (at least one line) - Terminator: "\n"
type SpanRecord ¶
type WebSocketClientFactory ¶
type WebSocketContext ¶
type WebSocketContext struct {
RequestID string
RemainingMS int
ConnectionID string
RouteKey string
DomainName string
Stage string
EventType string
ManagementEndpoint string
Body []byte
// contains filtered or unexported fields
}
func (*WebSocketContext) Context ¶
func (c *WebSocketContext) Context() context.Context
func (*WebSocketContext) NewID ¶
func (c *WebSocketContext) NewID() string
func (*WebSocketContext) Now ¶
func (c *WebSocketContext) Now() time.Time
func (*WebSocketContext) SendJSONMessage ¶
func (c *WebSocketContext) SendJSONMessage(value any) error
func (*WebSocketContext) SendMessage ¶
func (c *WebSocketContext) SendMessage(data []byte) error
type WebSocketHandler ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
lift-migrate
command
|
|
|
contract-tests
|
|
|
runners/go
command
|
|
|
examples
|
|
|
cdk/multilang/handlers/go
command
|
|
|
migration/rate-limited-http
command
|
|
|
pkg
|
|
|
limited
Package limited provides DynamoDB-backed rate limiting for AppTheory.
|
Package limited provides DynamoDB-backed rate limiting for AppTheory. |
|
limited/middleware
Package middleware provides HTTP middleware for the AppTheory limited rate limiter.
|
Package middleware provides HTTP middleware for the AppTheory limited rate limiter. |