Skip to content

Commit

Permalink
Merge pull request #65 from grafana/domas-make-request-limit-middlewa…
Browse files Browse the repository at this point in the history
…re-optional

feat: make request limit middleware optional
  • Loading branch information
domasx2 authored Jul 26, 2023
2 parents 06f9563 + 0fa76b5 commit 6b2a4f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/appcommon/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ func New(cfg Config, reg prometheus.Registerer, metricPrefix string, tracer open
authMiddleware = middleware.HTTPFakeAuth{}
}

requestLimitsMiddleware := middleware.NewRequestLimitsMiddleware(cfg.ServerConfig.HTTPMaxRequestSizeLimit)

// Middlewares will be wrapped in order
middlewares := []middleware.Interface{
tracerMiddleware,
instrumentMiddleware,
authMiddleware,
logMiddleware,
requestLimitsMiddleware,
}

if (cfg.ServerConfig.HTTPMaxRequestSizeLimit > 0) {
requestLimitsMiddleware := middleware.NewRequestLimitsMiddleware(cfg.ServerConfig.HTTPMaxRequestSizeLimit)
middlewares = append(middlewares, requestLimitsMiddleware)
}

srv, err := server.NewServer(logger, cfg.ServerConfig, router, middlewares)
Expand Down

0 comments on commit 6b2a4f9

Please sign in to comment.