web

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Recoverer = middleware.Recoverer

Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possible. Recoverer prints a request ID if one is provided.

Alternatively, look at https://github.com/go-chi/httplog middleware pkgs.

Functions

func Blob

func Blob[T ~[]byte | ~string](body T, contentType string, status int) http.HandlerFunc

func JSON

func JSON(value any, status int) http.HandlerFunc

func Redirect

func Redirect(to string, permanent ...bool) http.HandlerFunc

func Serve

func Serve(ctx context.Context, options ServeOption) (port int, err error)

func UseBasicAuth

func UseBasicAuth(r Router, username, password string)

UseBasicAuth implements a simple middleware handler for adding basic http auth to a route.

Types

type Router

type Router = chi.Router

func NewMux

func NewMux() Router

type ServeOption

type ServeOption struct {
	Handler    http.Handler
	Addr       string
	OnShutDown func(ctx context.Context)
}

Jump to

Keyboard shortcuts

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