Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authorVladimir Shushlin <v.shushlin@gmail.com>2021-12-08 19:41:26 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2021-12-13 15:46:55 +0300
commitc190b1fc1175110e0ad1cd5570033c039c2bc1fb (patch)
treec2b8b5e7634dd181dac537766e1551ab673bd105 /app.go
parent197d53c3f8c20942f76f111cc7bf6aac04c0dad4 (diff)
refactor: move ratelimiter configuration to handlers package
Diffstat (limited to 'app.go')
-rw-r--r--app.go16
1 files changed, 2 insertions, 14 deletions
diff --git a/app.go b/app.go
index 6030cad8..84eb8956 100644
--- a/app.go
+++ b/app.go
@@ -32,7 +32,6 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/logging"
"gitlab.com/gitlab-org/gitlab-pages/internal/netutil"
- "gitlab.com/gitlab-org/gitlab-pages/internal/ratelimiter"
"gitlab.com/gitlab-org/gitlab-pages/internal/rejectmethods"
"gitlab.com/gitlab-org/gitlab-pages/internal/request"
"gitlab.com/gitlab-org/gitlab-pages/internal/routing"
@@ -237,6 +236,7 @@ func setRequestScheme(r *http.Request) *http.Request {
return r
}
+// TODO: move the pipeline configuration to internal/pipeline https://gitlab.com/gitlab-org/gitlab-pages/-/issues/670
func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
// Handlers should be applied in a reverse order
handler := a.serveFileOrNotFoundHandler()
@@ -258,19 +258,7 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
handler = routing.NewMiddleware(handler, a.source)
- if a.config.RateLimit.SourceIPLimitPerSecond > 0 {
- rl := ratelimiter.New(
- "source_ip",
- ratelimiter.WithCacheMaxSize(ratelimiter.DefaultSourceIPCacheSize),
- ratelimiter.WithCachedEntriesMetric(metrics.RateLimitSourceIPCachedEntries),
- ratelimiter.WithCachedRequestsMetric(metrics.RateLimitSourceIPCacheRequests),
- ratelimiter.WithBlockedCountMetric(metrics.RateLimitSourceIPBlockedCount),
- ratelimiter.WithLimitPerSecond(a.config.RateLimit.SourceIPLimitPerSecond),
- ratelimiter.WithBurstSize(a.config.RateLimit.SourceIPBurst),
- )
-
- handler = rl.Middleware(handler)
- }
+ handler = handlers.Ratelimiter(handler, a.config)
// Health Check
handler, err = a.healthCheckMiddleware(handler)