srvu

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger Logger) context.Context

func Decode

func Decode(r *http.Request, t any, acceptEmpty bool) error

func Encode

func Encode(w http.ResponseWriter, v any) error

func Err

func Err(code int, err error) error

func ErrHandler

func ErrHandler(h Handler) http.Handler

func ErrHandlerFunc

func ErrHandlerFunc(h HandlerFunc) http.Handler

func ErrStr

func ErrStr(code int, err string) error

func RunServerGracefully

func RunServerGracefully(ctx context.Context, srv *http.Server, logger Logger) error

func With

func With(h http.Handler, mws ...Middleware) http.Handler

Types

type FormParser

type FormParser interface {
	FromForm(r *http.Request) error
}

type GzipResponseWriter

type GzipResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewGzipResponseWriter

func NewGzipResponseWriter(w http.ResponseWriter) *GzipResponseWriter

func (*GzipResponseWriter) Close

func (w *GzipResponseWriter) Close() error

func (*GzipResponseWriter) Write

func (w *GzipResponseWriter) Write(b []byte) (int, error)

type Handler

type Handler interface {
	ServeHTTP(context.Context, http.ResponseWriter, *http.Request) error
}

type HandlerFunc

type HandlerFunc func(context.Context, http.ResponseWriter, *http.Request) error

func (HandlerFunc) ServeHTTP

func (h HandlerFunc) ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type Logger

type Logger interface {
	Printf(string, ...any)
}

func GetLogger

func GetLogger(ctx context.Context) Logger

func LogToOutput

func LogToOutput(std Outputer) Logger

func NewLoggerFunc

func NewLoggerFunc(f func(string, ...any)) Logger

type LoggerFunc

type LoggerFunc func(string, ...any)

func (LoggerFunc) Printf

func (f LoggerFunc) Printf(format string, args ...any)

type Middleware

type Middleware func(http.Handler) http.Handler

func WithCacheCtrlHeader

func WithCacheCtrlHeader(ttl time.Duration) Middleware

func WithCompression

func WithCompression() Middleware

func WithLogger

func WithLogger(logger Logger) Middleware

type Outputer

type Outputer interface {
	Output(calldepth int, s string) error
}

type StatusError

type StatusError struct {
	Code int
	Err  error
}

func (StatusError) Error

func (s StatusError) Error() string

func (StatusError) Unwrap

func (s StatusError) Unwrap() error

Jump to

Keyboard shortcuts

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