registry: use exact match on path

This commit is contained in:
Blake Mizerany 2024-03-31 15:01:26 -07:00
parent 60ef0e6b4a
commit c0eddb10fd

View File

@ -8,7 +8,6 @@ import (
"errors" "errors"
"log" "log"
"net/http" "net/http"
"strings"
"time" "time"
"bllamo.com/client/ollama" "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 { func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) error {
switch { switch r.URL.Path {
case strings.HasPrefix(r.URL.Path, "/v1/push"): case "/v1/push":
return s.handlePush(w, r) return s.handlePush(w, r)
case strings.HasPrefix(r.URL.Path, "/v1/pull"): case "/v1/pull":
return s.handlePull(w, r) return s.handlePull(w, r)
} default:
return oweb.ErrNotFound return oweb.ErrNotFound
}
} }
func (s *Server) handlePush(w http.ResponseWriter, r *http.Request) error { func (s *Server) handlePush(w http.ResponseWriter, r *http.Request) error {