Skip to content
Merged
Prev Previous commit
Next Next commit
Attach rate limiter outside the pkg
  • Loading branch information
Emyrk committed Apr 4, 2023
commit 900709bf0201f09d60ca133630be33707f944484
5 changes: 4 additions & 1 deletion coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,10 @@ func New(options *Options) *API {
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("OK")) })

// Attach workspace apps routes.
workspaceAppServer.Attach(r, apiRateLimiter)
r.Group(func(r chi.Router) {
r.Use(apiKeyMiddleware)
workspaceAppServer.Attach(r)
})

r.Route("/derp", func(r chi.Router) {
r.Get("/", derpHandler.ServeHTTP)
Expand Down
3 changes: 1 addition & 2 deletions coderd/workspaceapps/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ type Server struct {
AppSigningKey SigningKey
}

func (s *Server) Attach(r chi.Router, pathAppRateLimiter func(http.Handler) http.Handler) {
func (s *Server) Attach(r chi.Router) {
servePathApps := func(r chi.Router) {
r.Use(pathAppRateLimiter)
r.HandleFunc("/*", s.workspaceAppsProxyPath)
}

Expand Down