Documentation ¶
Overview ¶
Package formam implements functions to decode values of a html form.
Index ¶
- Constants
- Variables
- func DispatchNext(context *Context, name string, writer http.ResponseWriter, ...) error
- type Context
- func (c *Context) BindForm(target interface{}) error
- func (c *Context) BindGetForm(target interface{}) error
- func (c *Context) BindJSON(target interface{}) error
- func (c *Context) Context() context.Context
- func (c *Context) GetBodyBytes() ([]byte, error)
- func (c *Context) GetBodyReader() io.ReadCloser
- func (c *Context) GetCookieValue(name string) (value string)
- func (c *Context) GetGetValue(name string) string
- func (c *Context) GetPostValue(name string) string
- func (c *Context) GetURLParameter(name string) string
- func (c *Context) Next() error
- func (c *Context) Printf(format string, v ...interface{}) (int, error)
- func (c *Context) Redirect(urlStr string)
- func (c *Context) RedirectStatus(urlStr string, httpStatus int)
- func (c *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 Registry *container.Registry // 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 Registry passed by the router // contains filtered or unexported fields }
Context holds context information about the incoming request
func GetContext ¶
GetContext gets a Context from the Registry context
func (*Context) BindGetForm ¶
BindGetForm decodes the request url values into target
func (*Context) GetBodyBytes ¶
func (*Context) GetBodyReader ¶
func (c *Context) GetBodyReader() io.ReadCloser
GetBodyReader returns bytes bodyReader
func (*Context) GetCookieValue ¶
GetCookieValue returns a cookie value from the request
func (*Context) GetGetValue ¶
GetGetValue returns a form value from the request, GetPostValue is shortcut for Context.Request.Form.Get method
func (*Context) GetPostValue ¶
GetPostValue returns a form value from the request, GetPostValue is shortcut for Context.Request.Form.Get method
func (*Context) GetURLParameter ¶
GetURLParameter returns a parameter from the url route, GetURLParameter 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
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.Registry and invoke DispatchNext which will invoke the next handler, the last handler is responsible for the main logic of the request. calling DispatchNext 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)