From 374fe655d35a34f2a7271cf560f72515568ee8b4 Mon Sep 17 00:00:00 2001 From: aishwarya-raimule Date: Mon, 23 Jan 2023 14:30:42 +0530 Subject: [PATCH] removed unused api handlers --- server/handlers.go | 69 ---------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/server/handlers.go b/server/handlers.go index 6665400..de77040 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -2,9 +2,6 @@ package server import ( "com.navi.medici.janus/lib" - "com.navi.medici.janus/schema" - - "fmt" "io" // "log" @@ -29,43 +26,6 @@ type CustomResponse struct { Message string `json:"message"` } -func eventsHandler(w http.ResponseWriter, r *http.Request) { - var reader io.Reader - - // for name, values := range r.Header { - // // Loop over all values for the name. - // for _, value := range values { - // fmt.Println("HEADER: ", name, value) - // } - // } - - // check if body is gzip compressed - if r.Header.Get("Content-Encoding") == "gzip" { - var err error - reader, err = gzip.NewReader(r.Body) - if err != nil { - // log.Printf(err) - w.Header().Set("Content-Type", "application/json") - http.Error(w, "Error while decompressing GZIP payload", http.StatusBadRequest) - return - } - } else { - reader = r.Body - } - - body, err := ioutil.ReadAll(reader) - if err != nil { - // log.Printf(err) - w.Header().Set("Content-Type", "application/json") - http.Error(w, "Request body invalid", http.StatusBadRequest) - return - } - - w.Header().Set("Content-Type", "application/json") - lib.ProtobufRequestChannel <- &lib.RequestObject{Body: body, Header: r.Header} - io.WriteString(w, "ok") -} - func eventsHandlerJson(w http.ResponseWriter, r *http.Request) { var reader io.Reader // check if body is gzip compressed @@ -111,32 +71,3 @@ func healthToggleHandler(w http.ResponseWriter, r *http.Request) { healthyBool = !healthyBool io.WriteString(w, "toggled") } - -func getSchemaHandler(w http.ResponseWriter, r *http.Request) { - schemaMapJson, _ := json.Marshal(schema.SchemaVersionMap) - w.Header().Set("Content-Type", "application/json") - w.Write(schemaMapJson) -} - -func refreshSchemaHandler(w http.ResponseWriter, r *http.Request) { - schema.GetSchemaVersions() - io.WriteString(w, "Updated Schema Map") -} - -func addSchemaHandler(w http.ResponseWriter, r *http.Request) { - body, _ := ioutil.ReadAll(r.Body) - - var bodyJson NewSchemaRequest - error := json.Unmarshal(body, &bodyJson) - fmt.Println(error) - - errorSchema := schema.AddSchema(bodyJson.Topic, bodyJson.SchemaType, bodyJson.Schema) - fmt.Println("errorSchema: ") - fmt.Println(error) - if errorSchema != nil { - http.Error(w, fmt.Sprintf("Error creating the schema %s", errorSchema), http.StatusBadRequest) - } else { - io.WriteString(w, "added") - } - -}