From 94fcf94f0a4837159e66b131169148b79ed13664 Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Sat, 14 Mar 2020 15:33:48 +0800 Subject: [PATCH] Answer faster in case of non-supported checksum database --- sumdb/handler.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sumdb/handler.go b/sumdb/handler.go index 12c4809..9695b00 100644 --- a/sumdb/handler.go +++ b/sumdb/handler.go @@ -35,12 +35,17 @@ func Handler(w http.ResponseWriter, r *http.Request) { return } - for _, supported := range supportedSumDB { - uri := fmt.Sprintf("/sumdb/%s/supported", supported) - if r.URL.Path == uri { - w.WriteHeader(http.StatusOK) - return + if strings.HasSuffix(r.URL.Path, "/supported") { + for _, supported := range supportedSumDB { + uri := fmt.Sprintf("/sumdb/%s/supported", supported) + if r.URL.Path == uri { + w.WriteHeader(http.StatusOK) + return + } } + + w.WriteHeader(http.StatusGone) + return } p := "https://" + strings.TrimPrefix(r.URL.Path, "/sumdb/")