30 lines
718 B
Go
30 lines
718 B
Go
|
package backend
|
||
|
|
||
|
import "net/http"
|
||
|
|
||
|
func AddRequestHeadersForProxy(req *http.Request) {
|
||
|
req.Header.Set("Connection", "Keep-Alive")
|
||
|
req.Header.Set("Accept-Language", "de-DE")
|
||
|
req.Header.Set("Referer", "https://control-center-app.1und1.de")
|
||
|
}
|
||
|
|
||
|
type backendRequestTransport struct {
|
||
|
underlyingTransport http.RoundTripper
|
||
|
}
|
||
|
|
||
|
func (t *backendRequestTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||
|
nreq := new(http.Request)
|
||
|
*nreq = *req
|
||
|
AddRequestHeadersForProxy(nreq)
|
||
|
return t.underlyingTransport.RoundTrip(nreq)
|
||
|
}
|
||
|
|
||
|
func BackendRequestTransport(t http.RoundTripper) http.RoundTripper {
|
||
|
if t == nil {
|
||
|
t = http.DefaultTransport
|
||
|
}
|
||
|
return &backendRequestTransport{
|
||
|
underlyingTransport: t,
|
||
|
}
|
||
|
}
|