Documentation ¶
Index ¶
- type Ctx
- func (c *Ctx) DecodeCookie(name string, dest *http.Cookie) error
- func (c *Ctx) JSON(status int, data interface{}) error
- func (c *Ctx) RenderHTML(name string, data H) error
- func (c *Ctx) Session(config *sessions.Config) (*sessions.Session, error)
- func (c *Ctx) SetCookie(cookie *http.Cookie) error
- func (c *Ctx) String(status int, data string) error
- type Engine
- func (e *Engine) Get(name string, handler ...Handler)
- func (e *Engine) GetRoute(name string, method string) (*Route, error)
- func (e *Engine) GetTemplate() *template.Template
- func (e *Engine) Post(name string, handler ...Handler)
- func (e *Engine) RegisterRoute(name, method string, handler ...Handler)
- func (e *Engine) Run(addr string)
- func (e *Engine) SetBodyParser(parser bodyparser.BodyParserI)
- func (e *Engine) SetErrorHandler(h Handler)
- func (e *Engine) SetTemplate(temp *template.Template)
- func (e *Engine) SetValidatorEngine(validator binding.ValidatorImpl)
- func (e *Engine) Static(path string, root http.FileSystem)
- type H
- type Handler
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ctx ¶
type Ctx struct { Error error // represents an error Req *http.Request // http request Res http.ResponseWriter // http response Params httprouter.Params // http params BodyParser bodyparser.BodyParserI // body parser // contains filtered or unexported fields }
request and response context
func (*Ctx) DecodeCookie ¶
Decodes encrypted cookie named 'name' to dest
func (*Ctx) JSON ¶
Sends JSON with 'application/json' content type. 'data' is a pointer to the struct, and it is a JSON unmarshalled object this function marshalls the JSON and sends it to the client
func (*Ctx) RenderHTML ¶
Renders given HTML template file with the std go templating engine
type Engine ¶
type Engine struct { MaxBodySize int64 // max request body size SecureCookie crypt.CrypterI // crypter to use for secure cookie impl Storage sessions.Store Timeout time.Duration // defines timeout for handlers // contains filtered or unexported fields }
Engine describes the engine for the HTTP server
func New ¶
func New() *Engine
Creates a new app instance.
Do not load crypter or secret keys from randomized keys each app startup. Rather load them from safe environments. Make sure for them to be 32 bytes long to satisfy AES-256
func (*Engine) Get ¶
Register POST route; shorthand for 'RegisterRoute'
func (*Engine) GetRoute ¶
Get existing route by name and it's method
func (*Engine) GetTemplate ¶
Gets the underlying templating engine if it is present
func (*Engine) Post ¶
Register GET route; shorthand for 'RegisterRoute'
func (*Engine) RegisterRoute ¶
Function to register route with all HTTP methods supported
func (*Engine) SetBodyParser ¶
func (e *Engine) SetBodyParser(parser bodyparser.BodyParserI)
Set custom body parser
func (*Engine) SetErrorHandler ¶
Set custom error handling function
func (*Engine) SetValidatorEngine ¶
func (e *Engine) SetValidatorEngine(validator binding.ValidatorImpl)
Define custom validator engine. Keep in mind that validator should be a struct pointer See: '/binding/validator.go' for example
func (*Engine) Static ¶
func (e *Engine) Static(path string, root http.FileSystem)
Serves static files