Documentation ¶
Index ¶
- Variables
- func Bind(r *http.Request, v Binder) error
- func Data(w http.ResponseWriter, r *http.Request, v []byte)
- func Decode(r *http.Request, v interface{}) error
- func DecodeForm(r *http.Request, v interface{}) (err error)
- func DecodeHeader(r *http.Request, v interface{}) error
- func DecodePath(r *http.Request, v interface{}) error
- func DecodePathContext(ctx context.Context, v interface{}) error
- func DecodeQuery(r *http.Request, v interface{}) error
- func EncodeHeader(w http.ResponseWriter, v interface{}) error
- func Error(w http.ResponseWriter, r *http.Request, err error)
- func ErrorJSON(w http.ResponseWriter, r *http.Request, err error)
- func ErrorXML(w http.ResponseWriter, r *http.Request, err error)
- func GetLogger(r *http.Request) log.Logger
- func HTML(w http.ResponseWriter, r *http.Request, v string)
- func JSON(w http.ResponseWriter, r *http.Request, v interface{})
- func NoContent(w http.ResponseWriter, r *http.Request)
- func PlainText(w http.ResponseWriter, r *http.Request, v string)
- func Print(routes chi.Routes)
- func RegisterValidation(tag string, fn validator.Func)
- func Render(w http.ResponseWriter, r *http.Request, v Renderer) error
- func Respond(w http.ResponseWriter, r *http.Request, v interface{})
- func Status(r *http.Request, status int)
- func UnmarshalForm(data []byte, v interface{}) error
- func Validate(r *http.Request, data interface{}) error
- func XML(w http.ResponseWriter, r *http.Request, v interface{})
- type Binder
- type Renderer
Constants ¶
This section is empty.
Variables ¶
var ErrNoRouteContextFound = fmt.Errorf("no route context found")
ErrNoRouteContextFound returns no route context error
Functions ¶
func Data ¶
func Data(w http.ResponseWriter, r *http.Request, v []byte)
Data writes raw bytes to the response, setting the Content-Type as application/octet-stream.
func Decode ¶
Decode is a package-level variable set to our default Decoder. We do this because it allows you to set render.Decode to another function with the same function signature, while also utilizing the render.Decoder() function itself. Effectively, allowing you to easily add your own logic to the package defaults. For example, maybe you want to impose a limit on the number of bytes allowed to be read from the request body.
func DecodeForm ¶
DecodeForm decodes an entity from form fields
func DecodeHeader ¶
DecodeHeader decodes an entity from query
func DecodePath ¶
DecodePath decodes an entity from path
func DecodePathContext ¶
DecodePath decodes an entity from path
func DecodeQuery ¶
DecodeQuery decodes an entity from query
func EncodeHeader ¶
func EncodeHeader(w http.ResponseWriter, v interface{}) error
EncodeHeader encodes a header
func Error ¶
func Error(w http.ResponseWriter, r *http.Request, err error)
Error injects the error within the request Deprecated: Use Respond instead
func ErrorJSON ¶
func ErrorJSON(w http.ResponseWriter, r *http.Request, err error)
ErrorJSON injects the error within the request Deprecated: Use JSON instead
func ErrorXML ¶
func ErrorXML(w http.ResponseWriter, r *http.Request, err error)
ErrorXML injects the error within the request Deprecated: Use XML instead
func HTML ¶
func HTML(w http.ResponseWriter, r *http.Request, v string)
HTML writes a string to the response, setting the Content-Type as text/html.
func JSON ¶
func JSON(w http.ResponseWriter, r *http.Request, v interface{})
JSON marshals 'v' to JSON, automatically escaping HTML and setting the Content-Type as application/json.
func NoContent ¶
func NoContent(w http.ResponseWriter, r *http.Request)
NoContent returns a HTTP 204 "No Content" response.
func PlainText ¶
func PlainText(w http.ResponseWriter, r *http.Request, v string)
PlainText writes a string to the response, setting the Content-Type as text/plain.
func RegisterValidation ¶
func RegisterValidation(tag string, fn validator.Func)
RegisterValidation adds a validation with the given tag
func Respond ¶
func Respond(w http.ResponseWriter, r *http.Request, v interface{})
Respond handles streaming JSON and XML responses, automatically setting the Content-Type based on request headers. It will default to a JSON response.
func Status ¶
Status sets a HTTP response status code hint into request context at any point during the request life-cycle. Before the Responder sends its response header it will check the StatusCtxKey
func UnmarshalForm ¶
UnmarshalForm unmashals form