Documentation
¶
Overview ¶
Package server provides the HTTP server for kumo.
Index ¶
- func DecodeCBORRequest(r *http.Request, v any) error
- func WriteCBORError(w http.ResponseWriter, code, message string, status int)
- func WriteCBORResponse(w http.ResponseWriter, v any)
- type CBORProtocolDispatcher
- type CBORServiceHandler
- type Config
- type JSONProtocolDispatcher
- type JSONServiceHandler
- type QueryProtocolDispatcher
- func (d *QueryProtocolDispatcher) Register(serviceName string, handler QueryServiceHandler)
- func (d *QueryProtocolDispatcher) RegisterAction(action, servicePrefix, serviceIdentifier string, handler QueryServiceHandler)
- func (d *QueryProtocolDispatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type QueryServiceHandler
- type Route
- type Router
- type Server
- func (s *Server) Addr() string
- func (s *Server) Handler() http.Handler
- func (s *Server) RegisterService(svc service.Service)
- func (s *Server) Registry() *service.Registry
- func (s *Server) Router() *Router
- func (s *Server) Run() error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Start(readyCh ...chan struct{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCBORRequest ¶
DecodeCBORRequest decodes a CBOR request body into the given value. It uses a custom DecMode that handles CBOR time tags (Tag 1).
func WriteCBORError ¶
func WriteCBORError(w http.ResponseWriter, code, message string, status int)
WriteCBORError writes an error response in CBOR format.
func WriteCBORResponse ¶
func WriteCBORResponse(w http.ResponseWriter, v any)
WriteCBORResponse writes a CBOR response with the smithy-protocol header. It uses a custom EncMode that outputs time values as CBOR time tags (Tag 1).
Types ¶
type CBORProtocolDispatcher ¶
type CBORProtocolDispatcher struct {
// contains filtered or unexported fields
}
CBORProtocolDispatcher routes Smithy RPC v2 CBOR protocol requests to the appropriate service based on the URL path: /service/{serviceName}/operation/{operationName}.
func NewCBORProtocolDispatcher ¶
func NewCBORProtocolDispatcher() *CBORProtocolDispatcher
NewCBORProtocolDispatcher creates a new CBOR protocol dispatcher.
func (*CBORProtocolDispatcher) Register ¶
func (d *CBORProtocolDispatcher) Register(serviceName string, handler CBORServiceHandler)
Register registers a service handler for the given service name. The service name matches the one in the URL path: /service/{serviceName}/operation/{operationName}.
func (*CBORProtocolDispatcher) ServeHTTP ¶
func (d *CBORProtocolDispatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler and dispatches to the appropriate service. It handles requests to /service/{serviceName}/operation/{operationName}.
type CBORServiceHandler ¶
type CBORServiceHandler func(w http.ResponseWriter, r *http.Request, operation string)
CBORServiceHandler handles RPC v2 CBOR protocol requests for a specific service.
type Config ¶
type Config struct {
Host string
Port int
LogLevel slog.Level
InitDir string // Directory containing init scripts to execute on startup
}
Config holds the server configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default server configuration. KUMO_HOST and KUMO_PORT override the bind address when set; an unparseable KUMO_PORT is ignored and the default port is kept. KUMO_LOG_LEVEL (debug|info|warn|error) overrides the default INFO level — useful when benchmarking, where per-request INFO logs dominate CPU.
type JSONProtocolDispatcher ¶
type JSONProtocolDispatcher struct {
// contains filtered or unexported fields
}
JSONProtocolDispatcher routes AWS JSON 1.0 protocol requests to the appropriate service based on the X-Amz-Target header prefix.
func NewJSONProtocolDispatcher ¶
func NewJSONProtocolDispatcher() *JSONProtocolDispatcher
NewJSONProtocolDispatcher creates a new JSON protocol dispatcher.
func (*JSONProtocolDispatcher) Register ¶
func (d *JSONProtocolDispatcher) Register(prefix string, handler JSONServiceHandler)
Register registers a service handler for the given target prefix. The prefix is the part before the dot in X-Amz-Target header, e.g., "AmazonSQS" for "AmazonSQS.CreateQueue" or "DynamoDB_20120810" for "DynamoDB_20120810.CreateTable".
func (*JSONProtocolDispatcher) ServeHTTP ¶
func (d *JSONProtocolDispatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler and dispatches to the appropriate service.
type JSONServiceHandler ¶
type JSONServiceHandler func(w http.ResponseWriter, r *http.Request)
JSONServiceHandler handles JSON protocol requests for a specific service.
type QueryProtocolDispatcher ¶
type QueryProtocolDispatcher struct {
// contains filtered or unexported fields
}
QueryProtocolDispatcher routes AWS Query protocol requests to the appropriate service based on the Action parameter and User-Agent header. The User-Agent header must contain an api/{service} token (set by AWS SDK v2) to identify the target service.
func NewQueryProtocolDispatcher ¶
func NewQueryProtocolDispatcher() *QueryProtocolDispatcher
NewQueryProtocolDispatcher creates a new Query protocol dispatcher.
func (*QueryProtocolDispatcher) Register ¶
func (d *QueryProtocolDispatcher) Register(serviceName string, handler QueryServiceHandler)
Register registers a service handler.
func (*QueryProtocolDispatcher) RegisterAction ¶
func (d *QueryProtocolDispatcher) RegisterAction(action, servicePrefix, serviceIdentifier string, handler QueryServiceHandler)
RegisterAction registers a handler for a specific action under a service identifier.
func (*QueryProtocolDispatcher) ServeHTTP ¶
func (d *QueryProtocolDispatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler and dispatches to the appropriate service.
type QueryServiceHandler ¶
type QueryServiceHandler func(w http.ResponseWriter, r *http.Request)
QueryServiceHandler handles Query protocol requests for a specific service.
type Route ¶
type Route struct {
Method string
Pattern string
Handler http.HandlerFunc
}
Route represents a registered HTTP route.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is the HTTP router for kumo.
func (*Router) Handle ¶
func (r *Router) Handle(method, pattern string, handler http.HandlerFunc)
Handle registers a handler for the given method and pattern.
func (*Router) HandleFunc ¶
func (r *Router) HandleFunc(method, pattern string, handler http.HandlerFunc)
HandleFunc is an alias for Handle for compatibility with service.Router interface.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main HTTP server for kumo.
func New ¶
New creates a new server with the given configuration. Services registered via init() are automatically loaded.
func (*Server) Handler ¶
Handler returns the HTTP handler for the server. This can be used with httptest.NewServer for in-process testing.
func (*Server) RegisterService ¶
RegisterService registers a service with the server.