Documentation
¶
Index ¶
- func Contexter() macaron.Handler
- func Toggle(options *ToggleOptions) macaron.Handler
- type Context
- func (c *Context) Error(err error, msg string)
- func (c *Context) Errorf(err error, format string, args ...interface{})
- func (c *Context) Fail(msg string)
- func (c *Context) FormErr(names ...string)
- func (c *Context) GetErrMsg() string
- func (c *Context) HTML(status int, name string)
- func (c *Context) HTMLString(name, content string)
- func (c *Context) HasError() bool
- func (c *Context) HasValue(name string) bool
- func (c *Context) NotFound()
- func (c *Context) NotFoundOrError(err error, msg string)
- func (c *Context) Ok(msg string)
- func (c *Context) PageIs(name string)
- func (c *Context) PlainText(status int, name []byte)
- func (c *Context) RawData(status int, v []byte)
- func (c *Context) RawTitle(title string)
- func (c *Context) RedirectSubpath(location string, status ...int)
- func (c *Context) RenderJSON(data interface{})
- func (c *Context) RenderWithErr(msg, tpl string, f interface{})
- func (c *Context) Require(name string)
- func (c *Context) ReturnJSON(code int64, msg string, data interface{})
- func (c *Context) ReturnLayuiJSON(code int64, msg string, count int, data interface{})
- func (c *Context) Success(name string)
- func (c *Context) Title(locale string)
- type JSONData
- type LayuiData
- type ToggleOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Toggle ¶
func Toggle(options *ToggleOptions) macaron.Handler
Types ¶
type Context ¶
type Context struct {
*macaron.Context
Cache cache.Cache
Flash *session.Flash
Session session.Store
Link string // Current request URL
IsLogged bool
IsBasicAuth bool
IsTokenAuth bool
// contains filtered or unexported fields
}
Context represents context of a request.
func (*Context) HTMLString ¶
func (*Context) NotFoundOrError ¶
NotFoundOrError responses with 404 page for not found error and 500 page otherwise.
func (*Context) RedirectSubpath ¶
RedirectSubpath responses redirection with given location and status. It prepends setting.Server.Subpath to the location string.
func (*Context) RenderJSON ¶
func (c *Context) RenderJSON(data interface{})
RenderJSON renders JSON response with status http.StatusOK
func (*Context) RenderWithErr ¶
RenderWithErr used for page has form validation but need to prompt error to users.
func (*Context) ReturnJSON ¶
ReturnJSON returns a standard JSON API response
func (*Context) ReturnLayuiJSON ¶
ReturnLayuiJSON returns a Layui table JSON response
type JSONData ¶
type JSONData struct {
Code int64 `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data,omitempty"`
}
JSONData represents the standard JSON API response structure
Click to show internal directories.
Click to hide internal directories.