diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 19:02:05 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 19:02:05 +0200 |
| commit | 1e63f5c91f0e5ff7dfc582b67d262d5939cc34bc (patch) | |
| tree | 7965a98e4bd286df502d658e687fa83230895c39 /web/request.go | |
| parent | 9ec4d3dbc1f55ca412f6df67b8576b087b15887c (diff) | |
Add global analytics page shell and split server.go by concern
Diffstat (limited to 'web/request.go')
| -rw-r--r-- | web/request.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/web/request.go b/web/request.go new file mode 100644 index 0000000..d51a582 --- /dev/null +++ b/web/request.go @@ -0,0 +1,36 @@ +package web + +import ( + "fmt" + "net/http" + "strings" +) + +func queryOrDefault(r *http.Request, key, fallback string) string { + if value := r.URL.Query().Get(key); value != "" { + return value + } + return fallback +} + +func syncNotice(r *http.Request) string { + imported := r.URL.Query().Get("imported") + if imported == "" { + return "" + } + return fmt.Sprintf("Sync complete: %s imported, %s skipped.", imported, r.URL.Query().Get("skipped")) +} + +func rideDetailNotice(r *http.Request) string { + if r.URL.Query().Get("official_climb") == "created" { + return "Official climb saved and matched to this ride by coordinates." + } + return "" +} + +func safeReturnTo(value string) string { + if value == "" || !strings.HasPrefix(value, "/") || strings.HasPrefix(value, "//") { + return "/sync" + } + return value +} |
