2016-01-29 09:46:11 +02:00
|
|
|
package standard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2016-03-13 01:06:52 +02:00
|
|
|
"mime/multipart"
|
2016-01-29 09:46:11 +02:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/engine"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Request struct {
|
2016-03-10 22:05:33 +02:00
|
|
|
*http.Request
|
|
|
|
url engine.URL
|
|
|
|
header engine.Header
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewRequest(r *http.Request) *Request {
|
|
|
|
return &Request{
|
2016-03-10 22:05:33 +02:00
|
|
|
Request: r,
|
|
|
|
url: &URL{URL: r.URL},
|
2016-01-29 09:46:11 +02:00
|
|
|
header: &Header{r.Header},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 07:13:08 +02:00
|
|
|
func (r *Request) TLS() bool {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.Request.TLS != nil
|
2016-02-23 07:13:08 +02:00
|
|
|
}
|
|
|
|
|
2016-02-23 07:26:36 +02:00
|
|
|
func (r *Request) Scheme() string {
|
|
|
|
if r.TLS() {
|
|
|
|
return "https"
|
|
|
|
}
|
|
|
|
return "http"
|
|
|
|
}
|
|
|
|
|
2016-02-09 18:12:37 +02:00
|
|
|
func (r *Request) Host() string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.Request.Host
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Request) URL() engine.URL {
|
|
|
|
return r.url
|
|
|
|
}
|
|
|
|
|
2016-02-09 02:48:03 +02:00
|
|
|
func (r *Request) Header() engine.Header {
|
|
|
|
return r.header
|
|
|
|
}
|
|
|
|
|
2016-02-11 02:51:43 +02:00
|
|
|
// func Proto() string {
|
|
|
|
// return r.request.Proto()
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func ProtoMajor() int {
|
|
|
|
// return r.request.ProtoMajor()
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func ProtoMinor() int {
|
|
|
|
// return r.request.ProtoMinor()
|
|
|
|
// }
|
|
|
|
|
2016-01-29 09:46:11 +02:00
|
|
|
func (r *Request) RemoteAddress() string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.RemoteAddr
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Request) Method() string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.Request.Method
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Request) URI() string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.RequestURI
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Request) Body() io.ReadCloser {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.Request.Body
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Request) FormValue(name string) string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return r.Request.FormValue(name)
|
2016-02-09 18:12:37 +02:00
|
|
|
}
|
|
|
|
|
2016-03-13 01:06:52 +02:00
|
|
|
func (r *Request) FormFile(name string) (*multipart.FileHeader, error) {
|
|
|
|
_, fh, err := r.Request.FormFile(name)
|
|
|
|
return fh, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Request) MultipartForm() (*multipart.Form, error) {
|
|
|
|
return r.Request.MultipartForm, nil
|
|
|
|
}
|
|
|
|
|
2016-02-05 00:40:08 +02:00
|
|
|
func (r *Request) reset(req *http.Request, h engine.Header, u engine.URL) {
|
2016-03-10 22:05:33 +02:00
|
|
|
r.Request = req
|
2016-02-05 00:40:08 +02:00
|
|
|
r.header = h
|
|
|
|
r.url = u
|
|
|
|
}
|