Scheme returns the HTTP protocol scheme, `http` or `https`.
()
| 210 | |
| 211 | // Scheme returns the HTTP protocol scheme, `http` or `https`. |
| 212 | func (c *Context) Scheme() string { |
| 213 | // Can't use `r.Request.URL.Scheme` |
| 214 | // See: https://groups.google.com/forum/#!topic/golang-nuts/pMUkBlQBDF0 |
| 215 | if c.IsTLS() { |
| 216 | return "https" |
| 217 | } |
| 218 | if scheme := c.request.Header.Get(HeaderXForwardedProto); isValidProto(scheme) { |
| 219 | return scheme |
| 220 | } |
| 221 | if scheme := c.request.Header.Get(HeaderXForwardedProtocol); isValidProto(scheme) { |
| 222 | return scheme |
| 223 | } |
| 224 | if ssl := c.request.Header.Get(HeaderXForwardedSsl); ssl == "on" { |
| 225 | return "https" |
| 226 | } |
| 227 | if scheme := c.request.Header.Get(HeaderXUrlScheme); isValidProto(scheme) { |
| 228 | return scheme |
| 229 | } |
| 230 | return "http" |
| 231 | } |
| 232 | |
| 233 | // RealIP returns the client IP address using the configured extraction strategy. |
| 234 | // |