1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-15 01:34:53 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-03-05 20:03:11 -08:00
parent 8916d5558c
commit a9c88cad63
16 changed files with 55 additions and 36 deletions

View File

@ -32,6 +32,7 @@ type (
Path() string
P(int) string
Param(string) string
ParamNames() []string
Query(string) string
Form(string) string
Set(string, interface{})
@ -148,6 +149,11 @@ func (c *context) Param(name string) (value string) {
return
}
// ParamNames returns path parameter names.
func (c *context) ParamNames() []string {
return c.pnames
}
// Query returns query parameter by name.
func (c *context) Query(name string) string {
return c.request.URL().QueryValue(name)
@ -174,7 +180,7 @@ func (c *context) Set(key string, val interface{}) {
// Bind binds the request body into specified type `i`. The default binder does
// it based on Content-Type header.
func (c *context) Bind(i interface{}) error {
return c.echo.binder.Bind(c.request, i)
return c.echo.binder.Bind(i, c)
}
// Render renders a template with data and sends a text/html response with status
@ -184,7 +190,7 @@ func (c *context) Render(code int, name string, data interface{}) (err error) {
return ErrRendererNotRegistered
}
buf := new(bytes.Buffer)
if err = c.echo.renderer.Render(buf, name, data); err != nil {
if err = c.echo.renderer.Render(buf, name, data, c); err != nil {
return
}
c.response.Header().Set(ContentType, TextHTMLCharsetUTF8)