Skip to content

Commit

Permalink
removed unused validateMethods function
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Valdron <mvaldron@redhat.com>
  • Loading branch information
michael-valdron committed Jul 29, 2022
1 parent 6868622 commit f3af869
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions index/server/pkg/server/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"strings"
"testing"

"github.com/devfile/registry-support/index/server/pkg/util"
"github.com/gin-gonic/gin"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand All @@ -35,30 +34,6 @@ func writeErrors(errors []responseError) ([]byte, error) {
})
}

func validateMethod(handle http.HandlerFunc, allowedMethods ...string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if arrayList := util.ConvertStringArrayToArrayList(allowedMethods); arrayList.Contains(r.Method) {
handle(w, r)
} else {
bytes, err := writeErrors([]responseError{
{
code: fmt.Sprintf("%d", http.StatusBadRequest),
message: fmt.Sprintf("%s method not supported for route %s", r.Method, r.URL.Path),
},
})
if err != nil {
log.Fatal(err)
}

w.WriteHeader(http.StatusBadRequest)
w.Header().Set("Content-Type", "application/json")
if _, err = w.Write(bytes); err != nil {
log.Fatal(err)
}
}
})
}

func servePing(c *gin.Context) {
data, err := json.Marshal(gin.H{
"message": "ok",
Expand Down

0 comments on commit f3af869

Please sign in to comment.