1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00

Get The HeaderXForwardedProto (#941)

* Get The HeaderXForwardedProto

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto

* add HeaderXForwardedSsl

* Get The HeaderXForwardedSsl
This commit is contained in:
TossPig 2017-06-05 00:41:17 +08:00 committed by Vishal Rana
parent 68b89eca6c
commit 353a2f8b78
2 changed files with 7 additions and 0 deletions

View File

@ -225,6 +225,12 @@ func (c *context) Scheme() string {
if c.IsTLS() {
return "https"
}
if scheme := c.request.Header.Get(HeaderXForwardedProto); scheme != "" {
return scheme
}
if ssl := c.request.Header.Get(HeaderXForwardedSsl); ssl == "on" {
return "https"
}
return "http"
}

View File

@ -184,6 +184,7 @@ const (
HeaderXForwardedProto = "X-Forwarded-Proto"
HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
HeaderXForwardedFor = "X-Forwarded-For"
HeaderXForwardedSsl = "X-Forwarded-Ssl"
HeaderXRealIP = "X-Real-IP"
HeaderXRequestID = "X-Request-ID"
HeaderServer = "Server"