Documentation
¶
Index ¶
- Constants
- func New() *router
- func RequestBody(req *http.Request, v interface{}) error
- func RequestBodyForm(req *http.Request, params map[string]string, v interface{}) error
- func RequestBodyJSON(req *http.Request, v interface{}) error
- func RequestBodyPost(req *http.Request, v interface{}) error
- func RequestParams(req *http.Request) []string
- func RequestQuery(req *http.Request, v interface{}) error
- func ServeError(w http.ResponseWriter, code int, reason ...string) error
- func ServeJSON(w http.ResponseWriter, v interface{}, code, indent uint) error
- func ServeText(w http.ResponseWriter, v string, code int)
- type ErrorResponse
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeText = "text/plain" ContentTypeMultipartForm = "multipart/form-data" ContentTypeUrlEncodedForm = "application/x-www-form-urlencoded" )
View Source
const (
PathSeparator = string(os.PathSeparator)
)
Variables ¶
This section is empty.
Functions ¶
func RequestBody ¶
RequestBody returns the body of a request as a struct
func RequestBodyForm ¶
RequestBodyForm returns the body of a request as a struct where the request is of type multipart/form-data
func RequestBodyJSON ¶
RequestBodyJSON returns the body of a request as a struct where the request is of type application/json
func RequestBodyPost ¶
RequestBodyPost returns the body of a request as a struct where the request is of type application/x-www-form-urlencoded
func RequestParams ¶
RequestParams returns the parameters encoded within the reqular expression
func RequestQuery ¶
RequestQuery returns the query string of a request as a struct
func ServeError ¶
func ServeError(w http.ResponseWriter, code int, reason ...string) error
ServeError is a utility function to serve a JSON error notice
Types ¶
type ErrorResponse ¶
Click to show internal directories.
Click to hide internal directories.