RequestURL populates (*http.Request).URL with the scheme and host.
()
| 18 | |
| 19 | // RequestURL populates (*http.Request).URL with the scheme and host. |
| 20 | func RequestURL() MiddlewareFunc { |
| 21 | return func(next http.Handler) http.Handler { |
| 22 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 23 | r.URL.Host = r.Host |
| 24 | r.URL.Scheme = schemeHTTP |
| 25 | if r.TLS != nil { |
| 26 | r.URL.Scheme = schemeHTTPS |
| 27 | } |
| 28 | next.ServeHTTP(w, r) |
| 29 | }) |
| 30 | } |
| 31 | } |