This commit is contained in:
jrc2139 2025-05-10 23:11:56 +03:00 committed by GitHub
commit 25a41783c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -1181,6 +1181,8 @@ func (s *Server) GenerateRoutes(rc *ollama.Registry) (http.Handler, error) {
r.GET("/", func(c *gin.Context) { c.String(http.StatusOK, "Ollama is running") })
r.HEAD("/api/version", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"version": version.Version}) })
r.GET("/api/version", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"version": version.Version}) })
r.HEAD("/health", func(c *gin.Context) { c.String(http.StatusOK, http.StatusText(http.StatusOK)) })
r.GET("/health", func(c *gin.Context) { c.String(http.StatusOK, http.StatusText(http.StatusOK)) })
// Local model cache management (new implementation is at end of function)
r.POST("/api/pull", s.PullHandler)

View file

@ -165,6 +165,27 @@ func TestRoutes(t *testing.T) {
}
},
},
{
Name: "Health Handler",
Method: http.MethodGet,
Path: "/health",
Setup: func(t *testing.T, req *http.Request) {
},
Expected: func(t *testing.T, resp *http.Response) {
contentType := resp.Header.Get("Content-Type")
if contentType != "text/plain; charset=utf-8" {
t.Errorf("expected content type text/plain; charset=utf-8, got %s", contentType)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("failed to read response body: %v", err)
}
expectedBody := http.StatusText(http.StatusOK)
if string(body) != expectedBody {
t.Errorf("expected body %s, got %s", expectedBody, string(body))
}
},
},
{
Name: "Tags Handler (no tags)",
Method: http.MethodGet,