added fix

This commit is contained in:
Nitin
2021-05-26 19:23:56 +05:30
parent a2bf87f0a6
commit 53878a03ca
2 changed files with 19 additions and 19 deletions

View File

@@ -4,26 +4,30 @@ import (
lib "com.navi.medici.janus/lib"
producer "com.navi.medici.janus/producer"
"io"
"fmt"
"io"
// "log"
"io/ioutil"
"net/http"
"compress/gzip"
"encoding/json"
"io/ioutil"
"net/http"
)
var (
healthyBool bool = true
)
type NewSchemaRequest struct {
Topic string `json:"topic"`
Schema string `json:"schema"`
SchemaType string `json:"schema_type"`
Topic string `json:"topic"`
Schema string `json:"schema"`
SchemaType string `json:"schema_type"`
}
type CustomResponse struct {
Code int `json:"code"`
Message string `json:"message"`
}
func eventsHandler(w http.ResponseWriter, r *http.Request) {
var reader io.Reader
@@ -62,7 +66,6 @@ func eventsHandler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "ok")
}
func eventsHandlerJson(w http.ResponseWriter, r *http.Request) {
var reader io.Reader
@@ -90,11 +93,12 @@ func eventsHandlerJson(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
lib.JsonRequestChannel <- &lib.RequestObject{Body: body, Header: r.Header}
io.WriteString(w, "ok")
//io.WriteString(w, "ok")
var rsp = CustomResponse{Code: 200, Message: "OK"}
json.NewEncoder(w).Encode(rsp)
}
func healthHandler(w http.ResponseWriter, r *http.Request) {
func healthHandler(w http.ResponseWriter, r *http.Request) {
if healthyBool {
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, "true")
@@ -104,27 +108,23 @@ func healthHandler(w http.ResponseWriter, r *http.Request) {
}
}
func healthToggleHandler(w http.ResponseWriter, r *http.Request) {
func healthToggleHandler(w http.ResponseWriter, r *http.Request) {
healthyBool = !healthyBool
io.WriteString(w, "toggled")
}
func getSchemaHandler(w http.ResponseWriter, r *http.Request) {
func getSchemaHandler(w http.ResponseWriter, r *http.Request) {
schemaMapJson, _ := json.Marshal(producer.SchemaVersionMap)
w.Header().Set("Content-Type", "application/json")
w.Write(schemaMapJson)
}
func refreshSchemaHandler(w http.ResponseWriter, r *http.Request) {
func refreshSchemaHandler(w http.ResponseWriter, r *http.Request) {
producer.GetSchemaVersions()
io.WriteString(w, "Updated Schema Map")
}
func addSchemaHandler(w http.ResponseWriter, r *http.Request) {
func addSchemaHandler(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
var bodyJson NewSchemaRequest

View File