1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-15 01:34:53 +02:00

Revert "Fixed Request.Out"

This reverts commit cced590a16.
This commit is contained in:
Vishal Rana
2015-12-21 15:18:53 -08:00
parent cced590a16
commit 72050d765b
8 changed files with 237 additions and 191 deletions

View File

@ -7,14 +7,13 @@ import (
"path/filepath"
"time"
"github.com/labstack/echo/engine"
"github.com/labstack/gommon/log"
"net/url"
"bytes"
netContext "golang.org/x/net/context"
xcontext "golang.org/x/net/context"
"golang.org/x/net/websocket"
)
@ -22,9 +21,9 @@ type (
// Context represents context for the current request. It holds request and
// response objects, path parameters, data and registered handler.
Context interface {
netContext.Context
Request() engine.Request
Response() engine.Response
xcontext.Context
Request() *http.Request
Response() *Response
Socket() *websocket.Conn
Path() string
P(int) string
@ -51,8 +50,8 @@ type (
}
context struct {
request engine.Request
response engine.Response
request *http.Request
response *Response
socket *websocket.Conn
path string
pnames []string
@ -66,7 +65,7 @@ type (
)
// NewContext creates a Context object.
func NewContext(req engine.Request, res engine.Response, e *Echo) Context {
func NewContext(req *http.Request, res *Response, e *Echo) Context {
return &context{
request: req,
response: res,
@ -93,12 +92,12 @@ func (c *context) Value(key interface{}) interface{} {
}
// Request returns *http.Request.
func (c *context) Request() engine.Request {
func (c *context) Request() *http.Request {
return c.request
}
// Response returns *Response.
func (c *context) Response() engine.Response {
func (c *context) Response() *Response {
return c.response
}
@ -136,17 +135,14 @@ func (c *context) Param(name string) (value string) {
// Query returns query parameter by name.
func (c *context) Query(name string) string {
if c.query == nil {
// TODO: v2
// c.query = c.request.URL.Query()
c.query = c.request.URL.Query()
}
return c.query.Get(name)
}
// Form returns form parameter by name.
func (c *context) Form(name string) string {
// TODO: v2
// return c.request.FormValue(name)
return ""
return c.request.FormValue(name)
}
// Get retrieves data from the context.
@ -298,8 +294,7 @@ func (c *context) Redirect(code int, url string) error {
if code < http.StatusMultipleChoices || code > http.StatusTemporaryRedirect {
return InvalidRedirectCode
}
// TODO: v2
// http.Redirect(c.response, c.request, url, code)
http.Redirect(c.response, c.request, url, code)
return nil
}
@ -318,11 +313,9 @@ func (c *context) X() *context {
return c
}
func (c *context) reset(req engine.Request, res engine.Response, e *Echo) {
c.request = req
// TODO: v2
// c.response.reset(res, e)
c.response = res
func (c *context) reset(r *http.Request, w http.ResponseWriter, e *Echo) {
c.request = r
c.response.reset(w, e)
c.query = nil
c.store = nil
c.echo = e