1
0
mirror of https://github.com/labstack/echo.git synced 2025-02-03 13:11:39 +02:00

Added Request#Scheme function

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-02-22 21:26:36 -08:00
parent 89551ddfd9
commit fb04f9979e
4 changed files with 15 additions and 3 deletions

View File

@ -18,6 +18,7 @@ type (
Request interface { Request interface {
TLS() bool TLS() bool
Scheme() string
Host() string Host() string
URI() string URI() string
URL() URL URL() URL

View File

@ -33,6 +33,10 @@ func (r *Request) TLS() bool {
return r.context.IsTLS() return r.context.IsTLS()
} }
func (r *Request) Scheme() string {
return string(r.context.URI().Scheme())
}
func (r *Request) Host() string { func (r *Request) Host() string {
return string(r.context.Host()) return string(r.context.Host())
} }

View File

@ -27,6 +27,13 @@ func (r *Request) TLS() bool {
return r.request.TLS != nil return r.request.TLS != nil
} }
func (r *Request) Scheme() string {
if r.TLS() {
return "https"
}
return "http"
}
func (r *Request) Host() string { func (r *Request) Host() string {
return r.request.Host return r.request.Host
} }

6
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: f220137e9ccd9aaf3051be33c3c23ea8abd2c40df6cf96175c3994d482b5e007 hash: f220137e9ccd9aaf3051be33c3c23ea8abd2c40df6cf96175c3994d482b5e007
updated: 2016-02-20T12:46:29.282847891-08:00 updated: 2016-02-22T21:25:23.014357426-08:00
imports: imports:
- name: github.com/klauspost/compress - name: github.com/klauspost/compress
version: f9625351863b5e94c1da72862187b8fe9a91af90 version: f9625351863b5e94c1da72862187b8fe9a91af90
@ -21,9 +21,9 @@ imports:
- name: github.com/mattn/go-isatty - name: github.com/mattn/go-isatty
version: 56b76bdf51f7708750eac80fa38b952bb9f32639 version: 56b76bdf51f7708750eac80fa38b952bb9f32639
- name: github.com/valyala/fasthttp - name: github.com/valyala/fasthttp
version: 58e4dea85db1b01e95b02e105b2a0e953c52694a version: 115b98672ee1c023598362dc74e9b04adaa7dede
- name: golang.org/x/net - name: golang.org/x/net
version: b6d7b1396ec874c3b00f6c84cd4301a17c56c8ed version: 0899459b4d84739aa2600ba248120318d78f8997
subpackages: subpackages:
- context - context
- websocket - websocket