feat: rate limiter lets api v1 requests through
This commit is contained in:
parent
7791c91960
commit
140419a1ca
2 changed files with 3 additions and 1 deletions
|
@ -38,6 +38,8 @@ public partial class InternalController(DatabaseContext db) : ControllerBase
|
||||||
{
|
{
|
||||||
if (template.StartsWith("api/v2"))
|
if (template.StartsWith("api/v2"))
|
||||||
template = template["api/v2".Length..];
|
template = template["api/v2".Length..];
|
||||||
|
else if (template.StartsWith("api/v1"))
|
||||||
|
template = template["api/v1".Length..];
|
||||||
template = PathVarRegex()
|
template = PathVarRegex()
|
||||||
.Replace(template, "{id}") // Replace all path variables (almost always IDs) with `{id}`
|
.Replace(template, "{id}") // Replace all path variables (almost always IDs) with `{id}`
|
||||||
.Replace("@me", "{id}"); // Also replace hardcoded `@me` with `{id}`
|
.Replace("@me", "{id}"); // Also replace hardcoded `@me` with `{id}`
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (hn *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// all public api endpoints are prefixed with this
|
// all public api endpoints are prefixed with this
|
||||||
if !strings.HasPrefix(r.URL.Path, "/api/v2") {
|
if !strings.HasPrefix(r.URL.Path, "/api/v2") && !strings.HasPrefix(r.URL.Path, "/api/v1") {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue