Skip to content

Commit

Permalink
Revert "Revert "Fixed Request.Out""
Browse files Browse the repository at this point in the history
This reverts commit 72050d7.
  • Loading branch information
Vishal Rana committed Dec 21, 2015
1 parent 72050d7 commit 33d8813
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 237 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

# **WORK IN PROGRESS!**

# [Echo](http://labstack.com/echo) [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/labstack/echo) [![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/labstack/echo/master/LICENSE) [![Build Status](http://img.shields.io/travis/labstack/echo.svg?style=flat-square)](https://travis-ci.org/labstack/echo) [![Coverage Status](http://img.shields.io/coveralls/labstack/echo.svg?style=flat-square)](https://coveralls.io/r/labstack/echo) [![Join the chat at https://gitter.im/labstack/echo](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg?style=flat-square)](https://gitter.im/labstack/echo)

A fast and unfancy micro web framework for Go.
Expand Down
37 changes: 22 additions & 15 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ import (
"path/filepath"
"time"

"github.com/labstack/echo/engine"
"github.com/labstack/gommon/log"

"net/url"

"bytes"

xcontext "golang.org/x/net/context"
netContext "golang.org/x/net/context"
"golang.org/x/net/websocket"
)

type (
// Context represents context for the current request. It holds request and
// response objects, path parameters, data and registered handler.
Context interface {
xcontext.Context
Request() *http.Request
Response() *Response
netContext.Context
Request() engine.Request
Response() engine.Response
Socket() *websocket.Conn
Path() string
P(int) string
Expand All @@ -50,8 +51,8 @@ type (
}

context struct {
request *http.Request
response *Response
request engine.Request
response engine.Response
socket *websocket.Conn
path string
pnames []string
Expand All @@ -65,7 +66,7 @@ type (
)

// NewContext creates a Context object.
func NewContext(req *http.Request, res *Response, e *Echo) Context {
func NewContext(req engine.Request, res engine.Response, e *Echo) Context {
return &context{
request: req,
response: res,
Expand All @@ -92,12 +93,12 @@ func (c *context) Value(key interface{}) interface{} {
}

// Request returns *http.Request.
func (c *context) Request() *http.Request {
func (c *context) Request() engine.Request {
return c.request
}

// Response returns *Response.
func (c *context) Response() *Response {
func (c *context) Response() engine.Response {
return c.response
}

Expand Down Expand Up @@ -135,14 +136,17 @@ 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 {
c.query = c.request.URL.Query()
// TODO: v2
// c.query = c.request.URL.Query()
}
return c.query.Get(name)
}

// Form returns form parameter by name.
func (c *context) Form(name string) string {
return c.request.FormValue(name)
// TODO: v2
// return c.request.FormValue(name)
return ""
}

// Get retrieves data from the context.
Expand Down Expand Up @@ -294,7 +298,8 @@ func (c *context) Redirect(code int, url string) error {
if code < http.StatusMultipleChoices || code > http.StatusTemporaryRedirect {
return InvalidRedirectCode
}
http.Redirect(c.response, c.request, url, code)
// TODO: v2
// http.Redirect(c.response, c.request, url, code)
return nil
}

Expand All @@ -313,9 +318,11 @@ func (c *context) X() *context {
return c
}

func (c *context) reset(r *http.Request, w http.ResponseWriter, e *Echo) {
c.request = r
c.response.reset(w, e)
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
c.query = nil
c.store = nil
c.echo = e
Expand Down
Loading

0 comments on commit 33d8813

Please sign in to comment.