mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor(agent/agentcontainers): implement API service (#17340)
This refactor improves separation of API and containers with minimal changes to logic. Highlights: - Routes are now defined in `agentcontainers` package - Handler renamed to API - API lazy init was moved into NewAPI - Tests that don't need to be internal were made external
This commit is contained in:
+8
-3
@@ -36,10 +36,15 @@ func (a *agent) apiHandler() http.Handler {
|
||||
ignorePorts: cpy,
|
||||
cacheDuration: cacheDuration,
|
||||
}
|
||||
ch := agentcontainers.New(agentcontainers.WithLister(a.lister))
|
||||
|
||||
containerAPI := agentcontainers.NewAPI(
|
||||
a.logger.Named("containers"),
|
||||
agentcontainers.WithLister(a.lister),
|
||||
)
|
||||
|
||||
promHandler := PrometheusMetricsHandler(a.prometheusRegistry, a.logger)
|
||||
r.Get("/api/v0/containers", ch.List)
|
||||
r.Post("/api/v0/containers/{id}/recreate", ch.Recreate)
|
||||
|
||||
r.Mount("/api/v0/containers", containerAPI.Routes())
|
||||
r.Get("/api/v0/listening-ports", lp.handler)
|
||||
r.Get("/api/v0/netcheck", a.HandleNetcheck)
|
||||
r.Post("/api/v0/list-directory", a.HandleLS)
|
||||
|
||||
Reference in New Issue
Block a user