1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-10 00:28:23 +02:00
echo/engine/standard/request.go
Vishal Rana 8ee864ae08 Dropped Engine**#Object functions
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-03-10 12:05:33 -08:00

86 lines
1.3 KiB
Go

package standard
import (
"io"
"net/http"
"github.com/labstack/echo/engine"
)
type (
Request struct {
*http.Request
url engine.URL
header engine.Header
}
)
func NewRequest(r *http.Request) *Request {
return &Request{
Request: r,
url: &URL{URL: r.URL},
header: &Header{r.Header},
}
}
func (r *Request) TLS() bool {
return r.Request.TLS != nil
}
func (r *Request) Scheme() string {
if r.TLS() {
return "https"
}
return "http"
}
func (r *Request) Host() string {
return r.Request.Host
}
func (r *Request) URL() engine.URL {
return r.url
}
func (r *Request) Header() engine.Header {
return r.header
}
// func Proto() string {
// return r.request.Proto()
// }
//
// func ProtoMajor() int {
// return r.request.ProtoMajor()
// }
//
// func ProtoMinor() int {
// return r.request.ProtoMinor()
// }
func (r *Request) RemoteAddress() string {
return r.RemoteAddr
}
func (r *Request) Method() string {
return r.Request.Method
}
func (r *Request) URI() string {
return r.RequestURI
}
func (r *Request) Body() io.ReadCloser {
return r.Request.Body
}
func (r *Request) FormValue(name string) string {
return r.Request.FormValue(name)
}
func (r *Request) reset(req *http.Request, h engine.Header, u engine.URL) {
r.Request = req
r.header = h
r.url = u
}