NewRedirection returns a new host (server supervisor) which redirects all requests to the target. Usage: target, _ := url.Parse("https://mydomain.com") r := NewRedirection(":80", target, 307) r.ListenAndServe() // use of `r.Shutdown` to close this server.
(hostAddr string, target *url.URL, redirectStatus int)
| 170 | // r := NewRedirection(":80", target, 307) |
| 171 | // r.ListenAndServe() // use of `r.Shutdown` to close this server. |
| 172 | func NewRedirection(hostAddr string, target *url.URL, redirectStatus int) *Supervisor { |
| 173 | redirectSrv := &http.Server{ |
| 174 | ReadTimeout: 30 * time.Second, |
| 175 | WriteTimeout: 60 * time.Second, |
| 176 | Addr: hostAddr, |
| 177 | Handler: RedirectHandler(target, redirectStatus), |
| 178 | } |
| 179 | |
| 180 | return New(redirectSrv) |
| 181 | } |
| 182 | |
| 183 | // RedirectHandler returns a simple redirect handler. |
| 184 | // See `NewProxy` or `ProxyHandler` for more features. |
nothing calls this directly
no test coverage detected
searching dependent graphs…