From c0eddb10fd98714583b2197dbd9f8ce84f328241 Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Sun, 31 Mar 2024 15:01:26 -0700 Subject: [PATCH] registry: use exact match on path --- registry/server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/registry/server.go b/registry/server.go index a12e210c..60605fc2 100644 --- a/registry/server.go +++ b/registry/server.go @@ -8,7 +8,6 @@ import ( "errors" "log" "net/http" - "strings" "time" "bllamo.com/client/ollama" @@ -35,13 +34,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) error { - switch { - case strings.HasPrefix(r.URL.Path, "/v1/push"): + switch r.URL.Path { + case "/v1/push": return s.handlePush(w, r) - case strings.HasPrefix(r.URL.Path, "/v1/pull"): + case "/v1/pull": return s.handlePull(w, r) + default: + return oweb.ErrNotFound } - return oweb.ErrNotFound } func (s *Server) handlePush(w http.ResponseWriter, r *http.Request) error {