Documentation ¶
Index ¶
- Constants
- func Decode(w http.ResponseWriter, r *http.Request, v interface{}) error
- func GetIntQueryParam(r *http.Request, key string, defaultValue int) int
- func GetQueryParam(r *http.Request, key, defaultValue string) string
- func Handle(h HandlerFunc) http.HandlerFunc
- func NewServer(host string, port uint16, handler http.Handler) *http.Server
- func NewSignalsChannel() chan os.Signal
- func Respond(w http.ResponseWriter, r *http.Request, code int, i interface{}) error
- func RespondJSON(w http.ResponseWriter, r *http.Request, code int, i interface{}) error
- func RespondText(w http.ResponseWriter, r *http.Request, code int, s string) error
- func StartServer(s *http.Server, c chan os.Signal) error
- type HandlerFunc
Constants ¶
View Source
const ( // ContentType content type HTTP header key ContentType = "Content-Type" // ContentTypeApplicationJSON JSON content type HTTP header value ContentTypeApplicationJSON = "application/json; charset=utf-8" // ContentTypeTextPlain text content type HTTP header value ContentTypeTextPlain = "text/plain; charset=utf-8" // PrettyParameter URL parameter for pretty printing JSON PrettyParameter = "pretty" )
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode(w http.ResponseWriter, r *http.Request, v interface{}) error
Decode decodes HTTP request data.
func GetIntQueryParam ¶ added in v0.3.0
GetIntQueryParam returns a request URL query parameter as an int or a default value.
func GetQueryParam ¶ added in v0.3.1
GetQueryParam returns a trimmed request URL query parameter or a default value.
func Handle ¶
func Handle(h HandlerFunc) http.HandlerFunc
Handle converts a Handler into a standard http.HandlerFunc
func NewSignalsChannel ¶
NewSignalsChannel creates a new channel for interrupt signals.
func RespondJSON ¶
RespondJSON encodes HTTP response data as JSON. Indentation can be controlled by a url query parameter 'pretty'.
func RespondText ¶
RespondText encodes HTTP response data as plain text.
Types ¶
type HandlerFunc ¶
type HandlerFunc func(w http.ResponseWriter, r *http.Request) error
HandlerFunc is a http.HandlerFunc that returns an error
Click to show internal directories.
Click to hide internal directories.