http

package
v0.0.0-...-d2e6534 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON[T any](r io.Reader) (T, error)

func EncodeJSON

func EncodeJSON(w http.ResponseWriter, code int, v any) error

func Error

func Error(w http.ResponseWriter, code int, err error, l *slog.Logger, a ...any) error

func GetIP

func GetIP(r *http.Request) string

GetIP returns the IP address of request.

func ListenAndServe

func ListenAndServe(ctx context.Context, s *http.Server) error

ListenAndServe allows graceful shutdown via context.Context cancellation.

func Response

func Response(w http.ResponseWriter, code int, v any) error

func StatusCodeIs

func StatusCodeIs(err error, code int) bool

StatusCodeIs matches an error to a status code.

func WriteHeaders

func WriteHeaders(w http.ResponseWriter, code int, headers ...ds.Pair[string, string])

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL