1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-10 00:28:23 +02:00
echo/engine/fasthttp/request.go
Vishal Rana bf97da9a16 Exclude fasthttp in appengine
Signed-off-by: Vishal Rana <vishal.rana@verizon.com>
2016-02-09 11:43:00 -08:00

67 lines
1.1 KiB
Go

// +build !appengine
package fasthttp
import (
"bytes"
"io"
"io/ioutil"
)
import (
"github.com/labstack/echo/engine"
"github.com/valyala/fasthttp"
)
type (
Request struct {
context *fasthttp.RequestCtx
url engine.URL
header engine.Header
}
)
func NewRequest(c *fasthttp.RequestCtx) *Request {
return &Request{
context: c,
url: &URL{url: c.URI()},
header: &RequestHeader{c.Request.Header},
}
}
func (r *Request) Host() string {
return string(r.context.Host())
}
func (r *Request) URI() string {
return string(r.context.RequestURI())
}
func (r *Request) URL() engine.URL {
return r.url
}
func (r *Request) Header() engine.Header {
return r.header
}
func (r *Request) RemoteAddress() string {
return r.context.RemoteAddr().String()
}
func (r *Request) Method() string {
return string(r.context.Method())
}
func (r *Request) Body() io.ReadCloser {
return ioutil.NopCloser(bytes.NewBuffer(r.context.PostBody()))
}
func (r *Request) FormValue(name string) string {
return ""
}
func (r *Request) Object() interface{} {
return r.context
}