From 1c39d1169a6ba45dbae75161472eb7e4213b5f1f Mon Sep 17 00:00:00 2001 From: Thayol Date: Sun, 13 Sep 2026 10:10:27 +0200 Subject: [PATCH] Retire old API routes --- internal/server/pages.go | 37 ------------------------------------- internal/server/server.go | 1 - 2 files changed, 38 deletions(-) diff --git a/internal/server/pages.go b/internal/server/pages.go index 41a5c58..cdcebc9 100644 --- a/internal/server/pages.go +++ b/internal/server/pages.go @@ -83,43 +83,6 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { }) } -type limitsJSON struct { - Name string `json:"name"` - Remembered bool `json:"remembered"` - MaxSize *int64 `json:"max_size"` // null means unlimited - MaxExpiry string `json:"max_expiry"` - DefaultExpiry string `json:"default_expiry"` - AllowVanity bool `json:"allow_vanity"` -} - -// handleLimits reports the permissions belonging to the presented credential, -// so the page can show what the caller may actually do. -func (s *Server) handleLimits(w http.ResponseWriter, r *http.Request) { - // Rate-limited like an upload: this is the one endpoint that reports - // whether a token is valid, and it should not be a free oracle. - if !s.limiter.allow(clientIP(r, s.cfg), s.now()) { - s.fail(w, r, http.StatusTooManyRequests, "Too many requests; try again shortly.") - return - } - lim, err := s.limitsFor(r, credential(r)) - if err != nil { - s.fail(w, r, http.StatusUnauthorized, "Unrecognised token.") - return - } - out := limitsJSON{ - Name: lim.Name, - Remembered: lim.Name != "" && bearer(r) == "", - MaxExpiry: config.FormatDuration(lim.MaxExpiry), - DefaultExpiry: config.FormatDuration(lim.DefaultExpiry), - AllowVanity: lim.AllowVanity, - } - if lim.MaxSize != config.Unlimited { - n := lim.MaxSize - out.MaxSize = &n - } - writeJSON(w, http.StatusOK, out) -} - type objectPage struct { page Meta *store.Meta diff --git a/internal/server/server.go b/internal/server/server.go index 397d3f6..6687d54 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -62,7 +62,6 @@ func (s *Server) routes() http.Handler { mux := http.NewServeMux() mux.HandleFunc("GET /{$}", s.handleIndex) mux.HandleFunc("POST /upload", s.handleUpload) - mux.HandleFunc("GET /api/limits", s.handleLimits) mux.HandleFunc("GET /admin", s.handleAdmin) mux.HandleFunc("GET /d/{id}", s.handleDownload) mux.HandleFunc("GET /i/{id}", s.handleInfo)