Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
4090aca9
Unverified
Commit
4090aca9
authored
May 06, 2025
by
Devon Rifkin
Committed by
GitHub
May 06, 2025
Browse files
server: send 405 instead of 404 for unallowed methods (#10275)
Fixes: #5483
parent
92ce438d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
server/routes.go
server/routes.go
+1
-0
server/routes_test.go
server/routes_test.go
+10
-0
No files found.
server/routes.go
View file @
4090aca9
...
...
@@ -1170,6 +1170,7 @@ func (s *Server) GenerateRoutes(rc *ollama.Registry) (http.Handler, error) {
corsConfig
.
AllowOrigins
=
envconfig
.
AllowedOrigins
()
r
:=
gin
.
Default
()
r
.
HandleMethodNotAllowed
=
true
r
.
Use
(
cors
.
New
(
corsConfig
),
allowedHostsMiddleware
(
s
.
addr
),
...
...
server/routes_test.go
View file @
4090aca9
...
...
@@ -485,6 +485,16 @@ func TestRoutes(t *testing.T) {
}
},
},
{
Name
:
"Method Not Allowed"
,
Method
:
http
.
MethodGet
,
Path
:
"/api/show"
,
Expected
:
func
(
t
*
testing
.
T
,
resp
*
http
.
Response
)
{
if
resp
.
StatusCode
!=
405
{
t
.
Errorf
(
"expected status code 405, got %d"
,
resp
.
StatusCode
)
}
},
},
}
modelsDir
:=
t
.
TempDir
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment