Documentation
¶
Index ¶
- func BindFromTags(v any, r *http.Request) error
- func HTTP[Req, Res any](act *action.BuiltAction[Req, Res], options ...AdapterOption) http.Handler
- func PopulateFromRequest(ctx context.Context, r *http.Request) context.Context
- func PropagateToResponse(ctx context.Context, w http.ResponseWriter)
- func ReadFormFile(r *http.Request, fieldName string, maxBytes int64) (data []byte, contentType string, err error)
- func RequestIdentity(next http.Handler) http.Handler
- func StreamIterator[T any](ctx context.Context, w http.ResponseWriter, seq iter.Seq2[T, error], ...) error
- func StreamNDJSON[E any](c codec.Codec, getIter func(ctx context.Context) (iter.Seq2[E, error], error)) http.HandlerFunc
- type AdapterConfig
- type AdapterOption
- type FormFile
- type HTTPDecoder
- type HTTPRoute
- type InMemoryBroadcaster
- type ListParams
- type Option
- type PathID
- type Query
- type RawHTTPHandler
- type SSERoute
- type StreamBroadcaster
- type Transport
- func (t *Transport) CanHandle(b action.Binding) bool
- func (t *Transport) Do(ctx context.Context, _ any) (any, error)
- func (t *Transport) Handler() http.Handler
- func (t *Transport) Mount(actions []action.AnyAction)
- func (t *Transport) Mux() *http.ServeMux
- func (t *Transport) String() string
- func (t *Transport) Use(mw ...func(http.Handler) http.Handler) *Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindFromTags ¶
BindFromTags extracts parameters from path, query, header, cookie, and form struct tags.
func HTTP ¶
func HTTP[Req, Res any](act *action.BuiltAction[Req, Res], options ...AdapterOption) http.Handler
func PopulateFromRequest ¶ added in v0.4.0
PopulateFromRequest reads correlation IDs from an HTTP request and returns a context containing them. It uses a valid W3C traceparent as a fallback for X-Trace-ID and X-Span-ID. Existing context IDs are retained when the request does not provide a value. Authorization-sensitive headers are not trusted.
func PropagateToResponse ¶ added in v0.4.0
func PropagateToResponse(ctx context.Context, w http.ResponseWriter)
PropagateToResponse writes correlation IDs to the response. Sensitive identity values are intentionally not reflected to HTTP clients.
func ReadFormFile ¶
func ReadFormFile(r *http.Request, fieldName string, maxBytes int64) (data []byte, contentType string, err error)
ReadFormFile extracts and reads a file from a multipart form request.
func RequestIdentity ¶ added in v0.4.0
RequestIdentity adds a pooled request scope, provisions or propagates correlation IDs, and records the URL path as the endpoint. It is installed automatically by Transport.Handler and can also be used on standalone HTTP handlers. It does not trust tenant/user/client-IP/approval headers.
Types ¶
type AdapterConfig ¶
type AdapterOption ¶
type AdapterOption func(*AdapterConfig)
func WithMaxBodyBytes ¶
func WithMaxBodyBytes(n int64) AdapterOption
func WithMethods ¶
func WithMethods(methods ...string) AdapterOption
type FormFile ¶
FormFile provides multipart/form-data upload decoding.
type HTTPDecoder ¶
type HTTPRoute ¶
func InferRoute ¶
InferRoute analyzes a Request struct type and generates standard RESTful routes at boot time.
type InMemoryBroadcaster ¶
type InMemoryBroadcaster struct {
// contains filtered or unexported fields
}
func NewBroadcaster ¶
func NewBroadcaster(buffer int) *InMemoryBroadcaster
func (*InMemoryBroadcaster) Publish ¶
func (b *InMemoryBroadcaster) Publish(channel string, payload []byte) (delivered, dropped int)
func (*InMemoryBroadcaster) Subscribe ¶
func (b *InMemoryBroadcaster) Subscribe(channel string) (events <-chan []byte, unsubscribe func())
type ListParams ¶
type ListParams struct {
Search string `json:"search" query:"search"`
Limit int `json:"limit" query:"limit"`
Page int `json:"page" query:"page"`
Sort string `json:"sort" query:"sort"`
}
ListParams is a standardized URL pagination and filter decoder.
func (*ListParams) FromHTTPRequest ¶
func (l *ListParams) FromHTTPRequest(r *http.Request) error
type Option ¶
type Option func(*Transport)
func WithBroadcaster ¶
func WithBroadcaster(b StreamBroadcaster) Option
func WithIdempotencyResponseLimit ¶ added in v0.3.0
func WithIdempotencyStore ¶
func WithIdempotencyStore(store action.IdempotencyStore) Option
func WithReadTimeout ¶
func WithWriteTimeout ¶
type PathID ¶
type PathID[T comparable] struct { ID T `json:"id"` }
PathID is a zero-allocation generic path parameter decoder for /{id}.
type Query ¶
type Query[T any] struct { Data T }
Query[T] fills any struct T from URL query parameters automatically.
type RawHTTPHandler ¶
type RawHTTPHandler struct {
Method string
Path string
Handler http.HandlerFunc
}
func RawHandler ¶
func RawHandler(method, path string, h http.HandlerFunc) RawHTTPHandler
func (RawHTTPHandler) String ¶
func (r RawHTTPHandler) String() string
type SSERoute ¶
type SSERoute struct {
Path string
Channel string
Broadcaster StreamBroadcaster
}
func (SSERoute) WithBroadcaster ¶
func (r SSERoute) WithBroadcaster(b StreamBroadcaster) SSERoute