@@ -648,6 +648,10 @@ func New(options *Options) *API {
648
648
httpmw .CSRF (options .SecureAuthCookie ),
649
649
)
650
650
651
+ // This incurs a performance hit from the middleware, but is required to make sure
652
+ // we do not override subdomain app routes.
653
+ r .Get ("/latency-check" , tracing .StatusWriterMiddleware (prometheusMW (LatencyCheck ())).ServeHTTP )
654
+
651
655
r .Get ("/healthz" , func (w http.ResponseWriter , r * http.Request ) { _ , _ = w .Write ([]byte ("OK" )) })
652
656
653
657
// Attach workspace apps routes.
@@ -1192,15 +1196,7 @@ func New(options *Options) *API {
1192
1196
// static files since it only affects browsers.
1193
1197
r .NotFound (cspMW (compressHandler (httpmw .HSTS (api .SiteHandler , options .StrictTransportSecurityCfg ))).ServeHTTP )
1194
1198
1195
- // This must be before all middleware to improve the response time.
1196
- // So make a new router, and mount the old one as the root.
1197
- rootRouter := chi .NewRouter ()
1198
- // This is the only route we add before all the middleware.
1199
- // We want to time the latency of the request, so any middleware will
1200
- // interfere with that timing.
1201
- rootRouter .Get ("/latency-check" , tracing .StatusWriterMiddleware (prometheusMW (LatencyCheck ())).ServeHTTP )
1202
- rootRouter .Mount ("/" , r )
1203
- api .RootHandler = rootRouter
1199
+ api .RootHandler = r
1204
1200
1205
1201
return api
1206
1202
}
0 commit comments