mirror of
https://github.com/labstack/echo.git
synced 2025-07-17 01:43:02 +02:00
22
context.go
22
context.go
@ -26,8 +26,8 @@ type (
|
||||
// response objects, path parameters, data and registered handler.
|
||||
Context interface {
|
||||
netContext.Context
|
||||
SetNetContext(netContext.Context)
|
||||
NetContext() netContext.Context
|
||||
SetNetContext(netContext.Context)
|
||||
Request() engine.Request
|
||||
Response() engine.Response
|
||||
Path() string
|
||||
@ -36,8 +36,8 @@ type (
|
||||
ParamNames() []string
|
||||
Query(string) string
|
||||
Form(string) string
|
||||
Set(string, interface{})
|
||||
Get(string) interface{}
|
||||
Set(string, interface{})
|
||||
Bind(interface{}) error
|
||||
Render(int, string, interface{}) error
|
||||
HTML(int, string) error
|
||||
@ -90,14 +90,14 @@ func NewContext(req engine.Request, res engine.Response, e *Echo) Context {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *context) SetNetContext(ctx netContext.Context) {
|
||||
c.netContext = ctx
|
||||
}
|
||||
|
||||
func (c *context) NetContext() netContext.Context {
|
||||
return c.netContext
|
||||
}
|
||||
|
||||
func (c *context) SetNetContext(ctx netContext.Context) {
|
||||
c.netContext = ctx
|
||||
}
|
||||
|
||||
func (c *context) Deadline() (deadline time.Time, ok bool) {
|
||||
return c.netContext.Deadline()
|
||||
}
|
||||
@ -169,11 +169,6 @@ func (c *context) Form(name string) string {
|
||||
return c.request.FormValue(name)
|
||||
}
|
||||
|
||||
// Get retrieves data from the context.
|
||||
func (c *context) Get(key string) interface{} {
|
||||
return c.store[key]
|
||||
}
|
||||
|
||||
// Set saves data in the context.
|
||||
func (c *context) Set(key string, val interface{}) {
|
||||
if c.store == nil {
|
||||
@ -182,6 +177,11 @@ func (c *context) Set(key string, val interface{}) {
|
||||
c.store[key] = val
|
||||
}
|
||||
|
||||
// Get retrieves data from the context.
|
||||
func (c *context) Get(key string) interface{} {
|
||||
return c.store[key]
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
Reference in New Issue
Block a user