http: add comment for ignored Atoi error, add request logging to onboarding gate
- handler.go: inline comment explaining ignored strconv.Atoi error (invalid explicit port falls through to preserve-as-is branch) - run.go: add middleware.RequestLogger(log) with no trusted proxy nets to directHTTPOnboardingGate so direct HTTP onboarding requests are logged using RemoteAddr only
- commit
- 6c74ee76e2a462a896c86a769cb927895be30d1f
- author
- brice · · 2026-04-01 09:53 UTC
- parent
- ef180bc
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +2 -0
M internal/adapters/in/http/onboarding/handler.go +1 -0
| @@ -60,6 +60,7 @@ func (h *Handler) publicHTTPSURL(r *http.Request) string { | |||
| 60 | 60 | return html.EscapeString("https://" + r.Host + "/") | |
| 61 | 61 | } | |
| 62 | 62 | ||
| 63 | + | // Ignore error: an invalid explicit port falls through to the preserve-as-is branch. | |
| 63 | 64 | port, _ := strconv.Atoi(portStr) | |
| 64 | 65 | if port == h.httpPort { | |
| 65 | 66 | return html.EscapeString(fmt.Sprintf("https://%s:%d/", host, h.tlsPort)) | |
| @@ -60,6 +60,7 @@ func (h *Handler) publicHTTPSURL(r *http.Request) string { | |||||
| 60 | return html.EscapeString("https://" + r.Host + "/") | 60 | return html.EscapeString("https://" + r.Host + "/") | ||
| 61 | } | 61 | } | ||
| 62 | 62 | ||||
| 63 | + | // Ignore error: an invalid explicit port falls through to the preserve-as-is branch. | |||
| 63 | port, _ := strconv.Atoi(portStr) | 64 | port, _ := strconv.Atoi(portStr) | ||
| 64 | if port == h.httpPort { | 65 | if port == h.httpPort { | ||
| 65 | return html.EscapeString(fmt.Sprintf("https://%s:%d/", host, h.tlsPort)) | 66 | return html.EscapeString(fmt.Sprintf("https://%s:%d/", host, h.tlsPort)) | ||
M internal/app/run.go +1 -0
| @@ -1727,6 +1727,7 @@ func directHTTPOnboardingGate(ob *onboarding.Handler, proxyNets []*net.IPNet, pr | |||
| 1727 | 1727 | ||
| 1728 | 1728 | onboardingWithMiddleware := middleware.Chain( | |
| 1729 | 1729 | middleware.PanicRecovery(log), | |
| 1730 | + | middleware.RequestLogger(log), // no trusted proxy nets — log RemoteAddr only | |
| 1730 | 1731 | middleware.SecurityHeaders, | |
| 1731 | 1732 | )(onboardingMux) | |
| 1732 | 1733 | ||
| @@ -1727,6 +1727,7 @@ func directHTTPOnboardingGate(ob *onboarding.Handler, proxyNets []*net.IPNet, pr | |||||
| 1727 | 1727 | ||||
| 1728 | onboardingWithMiddleware := middleware.Chain( | 1728 | onboardingWithMiddleware := middleware.Chain( | ||
| 1729 | middleware.PanicRecovery(log), | 1729 | middleware.PanicRecovery(log), | ||
| 1730 | + | middleware.RequestLogger(log), // no trusted proxy nets — log RemoteAddr only | |||
| 1730 | middleware.SecurityHeaders, | 1731 | middleware.SecurityHeaders, | ||
| 1731 | )(onboardingMux) | 1732 | )(onboardingMux) | ||
| 1732 | 1733 | ||||