| 103 | } |
| 104 | |
| 105 | func (l *LoggingRoundTripper) RoundTrip(r *http.Request) (resp *http.Response, err error) { |
| 106 | resp, err = l.RoundTripper.RoundTrip(r) |
| 107 | if resp.StatusCode == 429 { |
| 108 | log.Printf("%s Rate Limited: Retry-After %s on %s %s\n", l.Name, resp.Header.Get("Retry-After"), r.Method, r.URL.String()) |
| 109 | } else if resp.StatusCode >= 400 { |
| 110 | log.Printf("%s Request Failed: Unexpected status code %d on %s %s\n", l.Name, resp.StatusCode, r.Method, r.URL.String()) |
| 111 | } else if err != nil { |
| 112 | log.Printf("%s Request Failed: %s on %s %s\n", l.Name, err.Error(), r.Method, r.URL.String()) |
| 113 | } |
| 114 | return resp, err |
| 115 | } |
| 116 | |
| 117 | func applyLetsEncrypt(s *http.Server, conf *config.Configuration) { |
| 118 | httpClient := &http.Client{ |