Documentation ¶
Index ¶
- func DecodeJSON[T any](r io.Reader) (T, error)
- func EncodeJSON(w http.ResponseWriter, code int, v any) error
- func Error(w http.ResponseWriter, code int, err error, l *slog.Logger, a ...any) error
- func GetIP(r *http.Request) string
- func ListenAndServe(ctx context.Context, s *http.Server) error
- func Response(w http.ResponseWriter, code int, v any) error
- func StatusCodeIs(err error, code int) bool
- func WriteHeaders(w http.ResponseWriter, code int, headers ...ds.Pair[string, string])
- type UnexpectedStatusCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeJSON ¶
func EncodeJSON(w http.ResponseWriter, code int, v any) error
func ListenAndServe ¶
ListenAndServe allows graceful shutdown via context.Context cancellation.
func StatusCodeIs ¶
StatusCodeIs matches an error to a status code.
func WriteHeaders ¶
Types ¶
type UnexpectedStatusCode ¶
type UnexpectedStatusCode int
UnexpectedStatusCode represents status code as an error for convenience.
func (UnexpectedStatusCode) Error ¶
func (code UnexpectedStatusCode) Error() string
Error returns a formatted error message.
Click to show internal directories.
Click to hide internal directories.