web

package
v0.0.0-...-a050769 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r *http.Request, target interface{}) error

func LoggerMiddleware

func LoggerMiddleware(logger zerolog.Logger) func(next http.Handler) http.Handler

func RecovererMiddleware

func RecovererMiddleware(logger zerolog.Logger) func(next http.Handler) http.Handler

func RenderJSON

func RenderJSON(w http.ResponseWriter, v interface{}) error

func RenderString

func RenderString(w http.ResponseWriter, s string) error

func RenderStringf

func RenderStringf(w http.ResponseWriter, format string, args ...interface{}) error

func WrapHandler

func WrapHandler(f HandlerFunc) http.HandlerFunc

func WriteStatus

func WriteStatus(w http.ResponseWriter, status int, contentType string)

Types

type ErrorHandler

type ErrorHandler func(ResponseWriter, *http.Request, error)
var DefaultErrorHandler ErrorHandler = defaultErrorHandler

type HandlerFunc

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

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter

	// Status returns the HTTP status of the request, or 0 if one has not
	// yet been sent.
	Status() int

	// BytesWritten returns the total number of bytes sent to the client.
	BytesWritten() int

	// Unwrap returns the original proxied target.
	Unwrap() http.ResponseWriter
}

ResponseWriter is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.

func NewResponseWriter

func NewResponseWriter(w http.ResponseWriter, protoMajor int) ResponseWriter

NewResponseWriter wraps an http.ResponseWriter, returning a proxy that allows you to hook into various parts of the response process.

type StatusError

type StatusError interface {
	error
	Status() int
}

func NewError

func NewError(statusCode int, err error) StatusError

type TemplateSet

type TemplateSet struct {
	// contains filtered or unexported fields
}

func NewTemplateSet

func NewTemplateSet(rootFS fs.FS, logger zerolog.Logger) (*TemplateSet, error)

func (*TemplateSet) Render

func (ts *TemplateSet) Render(w io.Writer, name string, v interface{}) error

Jump to

Keyboard shortcuts

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