removed unused api handlers

This commit is contained in:
aishwarya-raimule
2023-01-23 14:30:42 +05:30
parent 4269298463
commit 374fe655d3

View File

@@ -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")
}
}