Documentation ¶
Index ¶
- Variables
- func CheckError(res http.ResponseWriter, req *http.Request, err error) bool
- func DeleteCookie(res http.ResponseWriter, req *http.Request, key string)
- func GetCookie(req *http.Request, name string) interface{}
- func GetStore(req *http.Request) *sessions.Session
- func InitSession()
- func JSONEncoding(req *http.Request) bool
- func JSONError(res http.ResponseWriter)
- func Render(res http.ResponseWriter, name string, data interface{})
- func SetCookie(res http.ResponseWriter, req *http.Request, key, value string)
- type Response
- type ViewData
Constants ¶
This section is empty.
Variables ¶
var (
// ViewsDir is the directory where all the views are being stored.
ViewsDir = "views"
)
Functions ¶
func CheckError ¶
CheckError returns true and sends the proper response if the given error is not nil. If the error is nil, then it just returns false and does nothing.
func DeleteCookie ¶
func DeleteCookie(res http.ResponseWriter, req *http.Request, key string)
DeleteCookie deletes the specified cookie.
func GetCookie ¶
GetCookie returns the value for the specified cookie. If the cookie does not exist, then an empty interface{} gets returned.
func GetStore ¶
GetStore tries to get the cookie store for the given request. It panics if it fails.
func JSONEncoding ¶
JSONEncoding returns true if we can assume that this is a JSON request, false otherwise.
func JSONError ¶
func JSONError(res http.ResponseWriter)
JSONError sends the standard error for this application.
func Render ¶
func Render(res http.ResponseWriter, name string, data interface{})
Render the view with the given name after evaluating the passed data. The rendered view will be written to the given writer.
Types ¶
type Response ¶
type Response struct { Message string `json:"msg,omitempty"` Error string `json:"error,omitempty"` }
Response for short messages.
type ViewData ¶
type ViewData struct { // The name of the javascript file to be used. JS string // The error message. Error string // Whether we are on print mode or not. Print bool }
ViewData holds all the data that can be passed to a view.
func DefaultViewData ¶
func DefaultViewData() *ViewData
DefaultViewData returns a ViewData object with the assets prefix set as expected.