httpsrv

package
v0.0.0-...-720f34a Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTemplate

func ExecuteTemplate(name string, w http.ResponseWriter, 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 map[string][]byte)

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 FS

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

func NewFS

func NewFS(m map[string][]byte) *FS

func (*FS) Open

func (fs *FS) Open(fname string) (http.File, error)

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