MCPcopy Index your code
hub / github.com/labstack/echo / Scheme

Method Scheme

context.go:212–231  ·  view source on GitHub ↗

Scheme returns the HTTP protocol scheme, `http` or `https`.

()

Source from the content-addressed store, hash-verified

210
211// Scheme returns the HTTP protocol scheme, `http` or `https`.
212func (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//

Callers 3

TestContext_SchemeFunction · 0.95
ToMiddlewareMethod · 0.80
ToMiddlewareMethod · 0.80

Calls 3

IsTLSMethod · 0.95
isValidProtoFunction · 0.85
GetMethod · 0.45

Tested by 1

TestContext_SchemeFunction · 0.76