diff --git a/server/handlers.go b/server/handlers.go index 71f05f4..79f3098 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -41,6 +41,15 @@ func eventsHandlerJson(w http.ResponseWriter, r *http.Request) { headerName := "X-Correlation-Id" substring := "abcdabcd-1234" headerValue, ok := r.Header[headerName] + if ok { + if strings.HasPrefix(headerValue[0], substring) { + w.Header().Set("Content-Type", "application/json") + var rsp = CustomResponse{Code: 200, Message: "OK"} + json.NewEncoder(w).Encode(rsp) + fmt.Println("Dropped blacklisted request") + return + } + } var reader io.Reader // check if body is gzip compressed @@ -67,17 +76,6 @@ func eventsHandlerJson(w http.ResponseWriter, r *http.Request) { return } - if ok { - if strings.HasPrefix(headerValue[0], substring) { - w.Header().Set("Content-Type", "application/json") - lib.JsonRequestChannel <- &lib.RequestObject{Body: body, Header: r.Header} - var rsp = CustomResponse{Code: 200, Message: "OK"} - json.NewEncoder(w).Encode(rsp) - fmt.Println("Dropped blacklisted request") - return - } - } - w.Header().Set("Content-Type", "application/json") lib.JsonRequestChannel <- &lib.RequestObject{Body: body, Header: r.Header} var rsp = CustomResponse{Code: 200, Message: "OK"}