Documentation
¶
Index ¶
- func DefaultValue[T Default]() T
- type Context
- type Default
- type FuncHandlerWrapper
- type Handler
- type HeadersContainer
- func (s *HeadersContainer) Add(key string, value string)
- func (s *HeadersContainer) Contains(key string) bool
- func (s *HeadersContainer) Delete(key string) []string
- func (s *HeadersContainer) Entries() iter.Seq2[string, []string]
- func (s *HeadersContainer) Get(key string) []string
- func (s *HeadersContainer) Set(key string, value string)
- type HttpError
- type HttpResponse
- type ILocalState
- type ISharedState
- type Response
- type Stackable
- func (s *Stackable[S, L]) AddHandler(handler Handler[S, L]) *Stackable[S, L]
- func (s Stackable[S, L]) AddUniqueHandler(handler Handler[S, L]) Stackable[S, L]
- func (s *Stackable[S, L]) HttpHandler() http.HandlerFunc
- func (s Stackable[S, L]) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (s *Stackable[S, L]) SetLogger(logger *slog.Logger)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultValue ¶
func DefaultValue[T Default]() T
Types ¶
type Context ¶
type Context[S ISharedState, L ILocalState] struct { Local *L Response Response Request *http.Request }
type FuncHandlerWrapper ¶
type FuncHandlerWrapper[S ISharedState, L ILocalState] struct { Handler func( context *Context[S, L], next func() error, ) error }
func WrapFunc ¶
func WrapFunc[S ISharedState, L ILocalState](handler func( context *Context[S, L], next func() error, ) error, ) FuncHandlerWrapper[S, L]
type Handler ¶
type Handler[S ISharedState, L ILocalState] interface { Run(context *Context[S, L], next func() error) error }
type HeadersContainer ¶
type HeadersContainer struct {
// contains filtered or unexported fields
}
func NewHeadersContainer ¶
func NewHeadersContainer() HeadersContainer
func (*HeadersContainer) Add ¶
func (s *HeadersContainer) Add(key string, value string)
func (*HeadersContainer) Contains ¶
func (s *HeadersContainer) Contains(key string) bool
func (*HeadersContainer) Delete ¶
func (s *HeadersContainer) Delete(key string) []string
func (*HeadersContainer) Get ¶
func (s *HeadersContainer) Get(key string) []string
func (*HeadersContainer) Set ¶
func (s *HeadersContainer) Set(key string, value string)
type HttpResponse ¶
type HttpResponse struct {
// contains filtered or unexported fields
}
func JsonResponse ¶
func JsonResponse(status int, data any) (*HttpResponse, error)
func NewHttpResponse ¶
func NewHttpResponse(status int, contentType string, body string) *HttpResponse
func NewHttpResponseRaw ¶
func NewHttpResponseRaw(headers HeadersContainer, status int, body io.Reader) *HttpResponse
func (*HttpResponse) Body ¶
func (r *HttpResponse) Body() io.Reader
func (*HttpResponse) Headers ¶
func (r *HttpResponse) Headers() HeadersContainer
func (*HttpResponse) SetHeaders ¶
func (r *HttpResponse) SetHeaders(newHeaders HeadersContainer)
func (*HttpResponse) Status ¶
func (r *HttpResponse) Status() int
type ILocalState ¶
type ILocalState interface {
Default
}
type ISharedState ¶
type ISharedState any
type Response ¶
type Response interface {
Headers() HeadersContainer
Body() io.Reader
Status() int
}
type Stackable ¶
type Stackable[S ISharedState, L ILocalState] struct { Handlers []Handler[S, L] // contains filtered or unexported fields }
func NewStackable ¶
func NewStackable[S ISharedState, L ILocalState](s *S) Stackable[S, L]
func (*Stackable[S, L]) AddHandler ¶
func (Stackable[S, L]) AddUniqueHandler ¶
func (*Stackable[S, L]) HttpHandler ¶
func (s *Stackable[S, L]) HttpHandler() http.HandlerFunc
Click to show internal directories.
Click to hide internal directories.