context

package
v0.0.0-...-fb7ad71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contexter

func Contexter() macaron.Handler

Contexter initializes a classic context for a request.

Types

type Context

type Context struct {
	*macaron.Context
	Flash   *session.Flash
	Session session.Store
}

func (*Context) HTML

func (c *Context) HTML(status int, name string)

HTML responses template with given status.

func (*Context) Handle

func (c *Context) Handle(status int, title string, err error)

Handle handles and logs error by given status.

func (*Context) HandleText

func (c *Context) HandleText(status int, title string)

func (*Context) JSONSuccess

func (c *Context) JSONSuccess(data interface{})

JSONSuccess responses JSON with status http.StatusOK.

func (*Context) NotFound

func (c *Context) NotFound()

NotFound renders the 404 page.

func (*Context) NotFoundOrServerError

func (c *Context) NotFoundOrServerError(title string, errck func(error) bool, err error)

NotFoundOrServerError use error check function to determine if the error is about not found. It responses with 404 status code for not found error, or error context description for logging purpose of 500 server error.

func (*Context) RawRedirect

func (c *Context) RawRedirect(location string, status ...int)

RawRedirect simply calls underlying Redirect method with no escape.

func (*Context) Redirect

func (c *Context) Redirect(location string, status ...int)

Redirect responses redirection wtih given location and status. It escapes special characters in the location string.

func (*Context) ServeEmbeddedContent

func (c *Context) ServeEmbeddedContent(name string, contentType string, r io.ReadSeeker)

func (*Context) ServerError

func (c *Context) ServerError(title string, err error)

ServerError renders the 500 page.

func (*Context) Success

func (c *Context) Success(name string)

Success responses template with status http.StatusOK.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL