Derive the entrypoint URL scheme from the shared TLS predicate (closes #272)
All checks were successful
check / check (push) Successful in 3m44s
All checks were successful
check / check (push) Successful in 3m44s
This commit was merged in pull request #286.
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
"sneak.berlin/go/webhooker/internal/database"
|
||||
"sneak.berlin/go/webhooker/internal/delivery"
|
||||
"sneak.berlin/go/webhooker/internal/reqtls"
|
||||
)
|
||||
|
||||
// WebhookListItem holds data for the webhook list view.
|
||||
@@ -427,16 +428,16 @@ func (h *Handlers) renderSourceDetail(
|
||||
}
|
||||
}
|
||||
|
||||
host := r.Host
|
||||
scheme := "https"
|
||||
|
||||
if r.TLS == nil {
|
||||
scheme = "http"
|
||||
scheme := "http"
|
||||
if reqtls.IsTLS(r) {
|
||||
scheme = "https"
|
||||
}
|
||||
|
||||
if fwdProto := r.Header.Get("X-Forwarded-Proto"); fwdProto != "" {
|
||||
scheme = fwdProto
|
||||
}
|
||||
// The host is the client's Host header, unvalidated. It is
|
||||
// inert only because source_detail.html renders BaseURL as
|
||||
// text inside a <code> element; putting it in an href or any
|
||||
// other URL context needs it constrained first.
|
||||
baseURL := scheme + "://" + r.Host
|
||||
|
||||
// The template calls Webhook methods, which take pointer
|
||||
// receivers; html/template cannot address a value stored in a map.
|
||||
@@ -448,7 +449,7 @@ func (h *Handlers) renderSourceDetail(
|
||||
"Entrypoints": NewEntrypointViews(entrypoints),
|
||||
"Targets": delivery.NewTargetViews(targets),
|
||||
"Events": events,
|
||||
"BaseURL": scheme + "://" + host,
|
||||
"BaseURL": baseURL,
|
||||
}
|
||||
|
||||
h.renderTemplate(w, r, "source_detail.html", data)
|
||||
|
||||
Reference in New Issue
Block a user