mirror of
https://github.com/labstack/echo.git
synced 2024-11-28 08:38:39 +02:00
fb04f9979e
Signed-off-by: Vishal Rana <vr@labstack.com>
81 lines
1.3 KiB
Go
81 lines
1.3 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) TLS() bool {
|
|
return r.context.IsTLS()
|
|
}
|
|
|
|
func (r *Request) Scheme() string {
|
|
return string(r.context.URI().Scheme())
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
func (r *Request) reset(c *fasthttp.RequestCtx, h engine.Header, u engine.URL) {
|
|
r.context = c
|
|
r.header = h
|
|
r.url = u
|
|
}
|