web

package
v0.0.0-...-d047845 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(handler func(http.ResponseWriter, *http.Request) error) http.HandlerFunc

ErrorHandler converts a handler with an error return to a http.HandlerFunc, sending a HTTP error code and a JSON formatted RFC 7807 problem detail document to the client appropriate for a given error.

func MethodNotAllowedHandler

func MethodNotAllowedHandler() http.HandlerFunc

MethodNotAllowedHandler returns a handler that serves a 405 Method Not Allowed error.

func MountAssets

func MountAssets(r chi.Router)

func MountData

func MountData(r chi.Router, rcs ...*zip.ReadCloser)

func NotFoundHandler

func NotFoundHandler() http.HandlerFunc

NotFoundHandler returns a handler that serves a 404 Not Found error.

func TrailingSlashRedirect

func TrailingSlashRedirect(w http.ResponseWriter, r *http.Request)

func WriteResponseBody

func WriteResponseBody(w http.ResponseWriter, b []byte) error

func WriteTemplateResponse

func WriteTemplateResponse(w http.ResponseWriter, tmpl Template, data interface{}) error

Types

type Template

type Template interface {
	Execute(io.Writer, interface{}) error
}

func NewTemplate

func NewTemplate(name string, funcs template.FuncMap) Template

Jump to

Keyboard shortcuts

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