Documentation ¶
Index ¶
- Variables
- func CORS(handler http.Handler) http.Handler
- func Handle(pattern string, ...)
- func IsProdAppEngine() bool
- func Serve(yamlPath string, handler http.Handler)
- func Static(yamlPath string, fallback http.Handler) (http.Handler, error)
- type ContentType
- type Handler
- type Redirect
- type Status
- type Template
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidStatusCode is generated when a Handler returns an out-of-range status code. ErrInvalidStatusCode = errors.New("status code <100 or >=600 specified") )
Functions ¶
func Handle ¶
func Handle(pattern string, handler func(w http.ResponseWriter, r *http.Request) interface{})
Handle is a convenience method around the Handler type.
func IsProdAppEngine ¶
func IsProdAppEngine() bool
IsProdAppEngine returns whether environment variables match the production App Engine environment.
Types ¶
type ContentType ¶
type ContentType struct { ContentType string Response interface{} }
ContentType wraps a Response a with specific Content-Type.
type Handler ¶
type Handler func(w http.ResponseWriter, r *http.Request) interface{}
Handler is the nicehttp helper type, allowing arbitrary return types from a HTTP handler. This supports:
- error to generate a StatusInternalServerError
- int for status code
- string to render directly
- the Template type to execute a template
- the Redirect type to cause a StatusSeeOther
- io.Reader to be piped to the output
- http.Handler to serve another real handler
- ... all other responses to be written as JSON, with ETag/If-Not-Modified support for GET
Additionally, wrapper types are supported:
- the ContentType type to wrap another repsonse with a given Content-Type header
- the Status type to wrap another response with a HTTP status code
Click to show internal directories.
Click to hide internal directories.