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 ReadFormFile(r *http.Request, fieldName string, maxBytes int64) ([]byte, string, error)
- 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 ReadFormFile ¶
ReadFormFile extracts and reads a file from a multipart form request.
Types ¶
type AdapterConfig ¶
type AdapterOption ¶
type AdapterOption func(*AdapterConfig)
func WithMaxBodyBytes ¶
func WithMaxBodyBytes(n int64) AdapterOption
func WithMethods ¶
func WithMethods(methods ...string) AdapterOption
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 int, dropped int)
func (*InMemoryBroadcaster) Subscribe ¶
func (b *InMemoryBroadcaster) Subscribe(channel string) (<-chan []byte, 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 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
func (SSERoute) WithChannel ¶
type StreamBroadcaster ¶
Click to show internal directories.
Click to hide internal directories.