internal: various cleanup
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I48f7eac2e99d1d2af02fcf237401be096a6a6964
This commit is contained in:
parent
0ca9d5b615
commit
56e1935ead
6 changed files with 33 additions and 48 deletions
|
|
@ -20,23 +20,25 @@ import (
|
|||
|
||||
// HTTP handler implementing the Nix binary cache protocol.
|
||||
type Server struct {
|
||||
router *router.Router
|
||||
prober *prober.Prober
|
||||
db *cache.DB
|
||||
upstreams []config.UpstreamConfig
|
||||
client *http.Client
|
||||
cachePriority int
|
||||
router *router.Router
|
||||
prober *prober.Prober
|
||||
db *cache.DB
|
||||
upstreams []config.UpstreamConfig
|
||||
client *http.Client
|
||||
cachePriority int
|
||||
metricsHandler http.Handler
|
||||
}
|
||||
|
||||
// Creates a Server.
|
||||
func New(r *router.Router, p *prober.Prober, db *cache.DB, upstreams []config.UpstreamConfig, cachePriority int) *Server {
|
||||
return &Server{
|
||||
router: r,
|
||||
prober: p,
|
||||
db: db,
|
||||
upstreams: upstreams,
|
||||
client: &http.Client{Timeout: 60 * time.Second},
|
||||
cachePriority: cachePriority,
|
||||
router: r,
|
||||
prober: p,
|
||||
db: db,
|
||||
upstreams: upstreams,
|
||||
client: &http.Client{Timeout: 60 * time.Second},
|
||||
cachePriority: cachePriority,
|
||||
metricsHandler: promhttp.Handler(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +50,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
case path == "/health":
|
||||
s.handleHealth(w, r)
|
||||
case path == "/metrics":
|
||||
promhttp.Handler().ServeHTTP(w, r)
|
||||
s.metricsHandler.ServeHTTP(w, r)
|
||||
case strings.HasSuffix(path, ".narinfo"):
|
||||
s.handleNarinfo(w, r)
|
||||
case strings.HasPrefix(path, "/nar/"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue