Skip to content

Commit 93a7a0e

Browse files
committed
allow POST method only for graphql handler
1 parent 99591f4 commit 93a7a0e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

internal/catalogd/storage/localdir.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ func (s *LocalDirV1) StorageServerHandler() http.Handler {
232232
allowedMethodsHandler := func(next http.Handler, allowedMethods ...string) http.Handler {
233233
allowedMethodSet := sets.New[string](allowedMethods...)
234234
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
235-
// Allow POST requests for GraphQL endpoint
236-
if r.URL.Path != "" && r.URL.Path[len(r.URL.Path)-7:] == "graphql" && r.Method == http.MethodPost {
237-
next.ServeHTTP(w, r)
235+
// Allow POST requests only for GraphQL endpoint
236+
if r.URL.Path != "" && r.URL.Path[len(r.URL.Path)-7:] != "graphql" && r.Method == http.MethodPost {
237+
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
238238
return
239239
}
240240
if !allowedMethodSet.Has(r.Method) {
@@ -244,7 +244,7 @@ func (s *LocalDirV1) StorageServerHandler() http.Handler {
244244
next.ServeHTTP(w, r)
245245
})
246246
}
247-
return allowedMethodsHandler(mux, http.MethodGet, http.MethodHead)
247+
return allowedMethodsHandler(mux, http.MethodGet, http.MethodHead, http.MethodPost)
248248
}
249249

250250
func (s *LocalDirV1) handleV1All(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)