httpsrv

package
v0.0.0-...-aa67389 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTemplate

func ExecuteTemplate(name string, w io.Writer, data interface{})

func FromForm

func FromForm(r *http.Request, s interface{}) error

FromForm fills struct `s` from the HTTP Form/Query values in `r`.

func LoadTemplates

func LoadTemplates(files fs.FS)

func SetHeader

func SetHeader(parent http.Handler, kv ...string) http.Handler

func SetHeaderMap

func SetHeaderMap(parent http.Handler, hdrs map[string]string) http.Handler

func WithLogging

func WithLogging(parent http.Handler) http.Handler

func WriteJSON

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

WriteJSON takes a struct in v, marshals it to JSON, and writes the output to w. It can be useful when writing HTTP handlers that output JSON. It calls http.Error to return a 500 error if the marshalling fails.

Types

type ParseError

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

ParseError represents errors when parsing the values.

Jump to

Keyboard shortcuts

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