Documentation ¶
Index ¶
- Variables
- type Cache
- type Decoder
- type DomainRequest
- type DomainRequestResponse
- type Encoder
- type Error
- type ErrorHandler
- type Handler
- func NewComplexRequestAdaptor[T any, R ValidatableNormalizable[T]](handler DomainRequest[T, R], factory RequestFactory[T, R]) (Handler, error)
- func NewComplexRequestResponseAdaptor[T any, R ValidatableNormalizable[T], P any](handler DomainRequestResponse[T, R, P], factory RequestFactory[T, R], ...) (Handler, error)
- func NewPanicRecoveryHandler(next Handler) Handler
- func NewPanicRecoveryMiddleware(next Handler) Handler
- func NewRequestAdaptor[T any, R ValidatableNormalizable[T]](handler DomainRequest[T, R], withOptions ...Option) (Handler, error)
- func NewRequestResponseAdaptor[T any, R ValidatableNormalizable[T], P any](handler DomainRequestResponse[T, R, P], withOptions ...Option) (Handler, error)
- func NewSlugRequestAdaptor(h func(context.Context, string) error) (Handler, error)
- func NewSlugRequestResponseAdaptor[R any](h func(context.Context, string) (R, error), withOptions ...Option) (Handler, error)
- type HashableByPage
- type InvalidRequestError
- type Middleware
- type NotFoundError
- type Option
- type Page
- type PageRequest
- type PanicError
- type RequestFactory
- type ValidatableNormalizable
Constants ¶
This section is empty.
Variables ¶
View Source
var DecoderJSON = func(v any, r io.Reader) error { return json.NewDecoder(r).Decode(&v) }
View Source
var EncoderJSON = func(w http.ResponseWriter, v any) error { w.Header().Set("Context-Type", "application/json") return json.NewEncoder(w).Encode(v) }
View Source
var ErrorTemplate string
Functions ¶
This section is empty.
Types ¶
type DomainRequest ¶ added in v0.0.3
type DomainRequest[T any, P ValidatableNormalizable[T]] func(context.Context, P) error
type DomainRequestResponse ¶ added in v0.0.3
type ErrorHandler ¶ added in v0.0.3
type ErrorHandler func(http.ResponseWriter, *http.Request, error)
func NewErrorHandlerHTML ¶ added in v0.0.3
func NewErrorHandlerHTML(l *slog.Logger, t *template.Template) ErrorHandler
func NewErrorHandlerJSON ¶ added in v0.0.3
func NewErrorHandlerJSON(l *slog.Logger) ErrorHandler
type Handler ¶
type Handler func(w http.ResponseWriter, r *http.Request) error
func NewComplexRequestAdaptor ¶ added in v0.0.3
func NewComplexRequestAdaptor[ T any, R ValidatableNormalizable[T], ]( handler DomainRequest[T, R], factory RequestFactory[T, R], ) (Handler, error)
func NewComplexRequestResponseAdaptor ¶ added in v0.0.3
func NewComplexRequestResponseAdaptor[ T any, R ValidatableNormalizable[T], P any, ]( handler DomainRequestResponse[T, R, P], factory RequestFactory[T, R], encoder Encoder, ) (Handler, error)
func NewPanicRecoveryHandler ¶ added in v0.0.5
NewPanicRecoveryHandler protects handlers from panics by converting them to errors.
See another variant: https://github.com/go-chi/chi/blob/v5.0.8/middleware/recoverer.go
func NewPanicRecoveryMiddleware ¶ added in v0.0.5
func NewRequestAdaptor ¶ added in v0.0.3
func NewRequestAdaptor[ T any, R ValidatableNormalizable[T], ]( handler DomainRequest[T, R], withOptions ...Option, ) (Handler, error)
func NewRequestResponseAdaptor ¶ added in v0.0.3
func NewRequestResponseAdaptor[ T any, R ValidatableNormalizable[T], P any, ]( handler DomainRequestResponse[T, R, P], withOptions ...Option, ) (Handler, error)
func NewSlugRequestAdaptor ¶ added in v0.0.3
type HashableByPage ¶
type InvalidRequestError ¶ added in v0.0.3
type InvalidRequestError struct {
// contains filtered or unexported fields
}
InvalidRequestError represents
func NewInvalidRequestError ¶ added in v0.0.3
func NewInvalidRequestError(fromError error) *InvalidRequestError
func (*InvalidRequestError) Error ¶ added in v0.0.3
func (e *InvalidRequestError) Error() string
func (*InvalidRequestError) HTTPStatusCode ¶ added in v0.0.3
func (e *InvalidRequestError) HTTPStatusCode() int
func (*InvalidRequestError) Unwrap ¶ added in v0.0.3
func (e *InvalidRequestError) Unwrap() error
type Middleware ¶
func NewErrorHandlerMiddleware ¶ added in v0.0.3
func NewErrorHandlerMiddleware(h ErrorHandler) Middleware
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
func NewNotFoundError ¶
func NewNotFoundError(resource string) *NotFoundError
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) HTTPStatusCode ¶
func (e *NotFoundError) HTTPStatusCode() int
type Option ¶ added in v0.0.3
type Option func(*options) error
func WithDecoder ¶ added in v0.0.3
func WithDefaultOptions ¶ added in v0.0.3
func WithDefaultOptions() Option
func WithEncoder ¶ added in v0.0.3
func WithEncodingJSON ¶ added in v0.0.3
func WithEncodingJSON() Option
func WithReadLimit ¶ added in v0.0.3
type PageRequest ¶
type PageRequest[T any, H HashableByPage[T]] struct { Query H Page int PerPage int }
type PanicError ¶ added in v0.0.5
type PanicError struct {
// contains filtered or unexported fields
}
func (*PanicError) Error ¶ added in v0.0.5
func (e *PanicError) Error() string
func (*PanicError) HTTPStatusCode ¶ added in v0.0.5
func (e *PanicError) HTTPStatusCode() int
func (*PanicError) LogValue ¶ added in v0.0.5
func (e *PanicError) LogValue() slog.Value
type RequestFactory ¶
type RequestFactory[T any, P ValidatableNormalizable[T]] func( w http.ResponseWriter, r *http.Request, ) (P, error)
type ValidatableNormalizable ¶ added in v0.0.3
ValidatableNormalizable constrains a domain request. Validation and normalization errors will be wrapped as InvalidRequestError by the adapter.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
botswat
module
|
|
turnstile
Package turnstile creates a secure by default humanity verifier backed by Cloudflare's Turnstile service.
|
Package turnstile creates a secure by default humanity verifier backed by Cloudflare's Turnstile service. |
Package oakclient provides a secure HTTP client.
|
Package oakclient provides a secure HTTP client. |
oakoidc
module
|
|
Package oakrouter provides an ugly [oakhttp.Handler] multiplexer as a hashmap router paired with a [http.Method] switch.
|
Package oakrouter provides an ugly [oakhttp.Handler] multiplexer as a hashmap router paired with a [http.Method] switch. |
Package oakserver provides a standard library [http.Server] with conventional production defaults and a smooth configuration interface.
|
Package oakserver provides a standard library [http.Server] with conventional production defaults and a smooth configuration interface. |
Click to show internal directories.
Click to hide internal directories.