mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Workspace Proxy picker show latency to each proxy (#7486)
* chore: Add cors to workspace proxies to allow for latency checks * Add latency check to wsproxy Use performance API timings. - Fix cors and timing headers - Accept custom headers
This commit is contained in:
@ -806,6 +806,17 @@ func New(options *Options) *API {
|
||||
return []string{}
|
||||
})
|
||||
r.NotFound(cspMW(compressHandler(http.HandlerFunc(api.siteHandler.ServeHTTP))).ServeHTTP)
|
||||
|
||||
// This must be before all middleware to improve the response time.
|
||||
// So make a new router, and mount the old one as the root.
|
||||
rootRouter := chi.NewRouter()
|
||||
// This is the only route we add before all the middleware.
|
||||
// We want to time the latency of the request, so any middleware will
|
||||
// interfere with that timing.
|
||||
rootRouter.Get("/latency-check", LatencyCheck(api.AccessURL))
|
||||
rootRouter.Mount("/", r)
|
||||
api.RootHandler = rootRouter
|
||||
|
||||
return api
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user