Documentation ¶
Index ¶
- Variables
- func Decode(r *request.Request, data interface{}) error
- func Encode(r *request.Request, data interface{}, status ...ResponseStatus) error
- func JSON(r *request.Request, jsonResponse *JSONResponse) error
- func Render(r *request.Request, templateName string) error
- func RenderTemplate(r *request.Request, t *template.Template, name string) error
- func String(r *request.Request, templateString string) error
- type JSONResponse
- type ResponseStatus
Constants ¶
This section is empty.
Variables ¶
View Source
var DEFAULT_DATA_FUNC func(r *request.Request)
View Source
var TEMPLATE_MANAGER *templates.Manager
Functions ¶
func Encode ¶
func Encode(r *request.Request, data interface{}, status ...ResponseStatus) error
Render json to a request. Response will be in the form of:
{ "status": "ok", "data": { "key": "value" } }
func JSON ¶
func JSON(r *request.Request, jsonResponse *JSONResponse) error
Encode json to a request.
func Render ¶
Template configuration must be set before calling this function!
See the templates package for more information.
func RenderTemplate ¶
Render a template with the given name
Types ¶
type JSONResponse ¶
type JSONResponse struct { Next string `json:"next,omitempty"` Detail string `json:"detail,omitempty"` Status ResponseStatus `json:"status"` Data interface{} `json:"data"` }
Default json response which gets returned when using (j).Encode().
type ResponseStatus ¶
type ResponseStatus string
const ( ResponseStatusOK ResponseStatus = "ok" ResponseStatusError ResponseStatus = "error" ResponseStatusRedirect ResponseStatus = "redirect" )
Click to show internal directories.
Click to hide internal directories.