get schema versions

This commit is contained in:
“nishant-sharma”
2021-05-06 16:18:54 +05:30
parent bb9ce0fbb9
commit c1287d3c34
2 changed files with 11 additions and 1 deletions

View File

@@ -2,13 +2,15 @@ package server
import (
lib "com.navi.medici.janus/lib"
producer "com.navi.medici.janus/producer"
"io"
// "fmt"
// "log"
"io/ioutil"
"log"
"net/http"
"compress/gzip"
"encoding/json"
)
var (
@@ -100,3 +102,10 @@ 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(producer.SchemaVersionMap)
w.Header().Set("Content-Type", "application/json")
w.Write(schemaMapJson)
}

View File

@@ -34,6 +34,7 @@ func NewServer(port string) (*Server, error) {
router.HandleFunc("/events/json", eventsHandlerJson).Methods("POST")
router.HandleFunc("/health", healthHandler).Methods("GET")
router.HandleFunc("/health/toggle", healthToggleHandler).Methods("GET")
router.HandleFunc("/schema/get", getSchemaHandler).Methods("GET")
// router.HandleFunc("/test", testHandler).Methods("GET")
// router.HandleFunc("/schema/refresh", schemaRefreshHandler).Methods("POST")
// router.HandleFunc("/stop", stopHandler).Methods("POST")