Documentation ¶
Overview ¶
Package formam implements functions to decode values of a html form.
Index ¶
- Constants
- Variables
- func Advance(c *Context, name string, w http.ResponseWriter, r *http.Request, ...)
- type Context
- func (ctx *Context) Advance() error
- func (ctx *Context) BindForm(target interface{}) error
- func (ctx *Context) BindGetForm(target interface{}) error
- func (ctx *Context) BindJSON(target interface{}) error
- func (ctx *Context) CookieByName(name string) (value string)
- func (ctx *Context) FormByName(name string) string
- func (ctx *Context) ParamByName(name string) string
- func (ctx *Context) Printf(format string, v ...interface{}) (int, error)
- func (ctx *Context) Redirect(urlStr string)
- func (ctx *Context) RedirectStatus(urlStr string, httpStatus int)
- func (ctx *Context) URLFormByName(name string) string
- func (ctx *Context) WriteString(txt string) (int, error)
- type Handler
- type HandlerFunc
Constants ¶
const TAG_NAME = "formam"
Variables ¶
var ContextType = reflect.TypeOf((*Context)(nil))
Functions ¶
Types ¶
type Context ¶
type Context struct { Name string // The name associated with the route IoC *container.IoC // Dependency injection context Request *http.Request // Request data passed by the router Gen *common.URLGen Response http.ResponseWriter // Response Writer passed by the router Parameters router.Parameter // Route Variables passed by the router // contains filtered or unexported fields }
Context holds context information about the incoming request
func GetContext ¶
GetContext get's a Context from the Global context
func (*Context) BindGetForm ¶
BindGetForm decodes the request url values into target
func (*Context) CookieByName ¶
CookieByName returns a cookie value from the request
func (*Context) FormByName ¶
FormByName returns a form value from the request, FormByName is shortcut for Context.Request.Form.Get method
func (*Context) ParamByName ¶
ParamByName returns a parameter from the url route, ParamByName is shortcut for Context.Parameters.ByName method
func (*Context) Redirect ¶
Redirect redirects the request to the specified urlStr and send a http StatusFound code
func (*Context) RedirectStatus ¶
RedirectStatus redirects the request to the specified urlStr and send the the status code specified by httpStatus
func (*Context) URLFormByName ¶
URLFormByName returns a form value from the request, FormByName is shortcut for Context.Request.Form.Get method
type Handler ¶
type Handler interface {
Handle(*Context)
}
Handler is responsible to handle the request or part of the request, ex: a middleware handler would process some data put the data into the scope.Variables and invoke Advance which will invoke the next handler, the last handler is responsible for the main logic of the request. calling Advance in the last handler will panic.
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc func implementing Handler interface
func (HandlerFunc) Handle ¶
func (fn HandlerFunc) Handle(c *Context)