fix(go): Registry API acknowledgement URI has a trailing slash

Previously the acknowledgement calls from Docker were receiving a
404 (which apparently doesn't bother it?!). This corrects the URL,
which meant that acknowledgement had to move inside of the
registryHandler.
This commit is contained in:
Vincent Ambo 2019-08-03 01:18:14 +01:00 committed by Vincent Ambo
parent 18ef0d56fd
commit f2d272b835

12
main.go
View File

@ -367,6 +367,11 @@ type registryHandler struct {
}
func (h *registryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Acknowledge that we speak V2 with an empty response
if r.RequestURI == "/v2/" {
return
}
// Serve the manifest (straight from Nix)
manifestMatches := manifestRegex.FindStringSubmatch(r.RequestURI)
if len(manifestMatches) == 3 {
@ -436,12 +441,7 @@ func main() {
log.Printf("Starting Kubernetes Nix controller on port %s\n", cfg.port)
// Acknowledge that we speak V2
http.HandleFunc("/v2", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w)
})
// All other /v2/ requests belong to the registry handler.
// All /v2/ requests belong to the registry handler.
http.Handle("/v2/", &registryHandler{
cfg: cfg,
ctx: &ctx,