write to kafka using request handler channel
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
lib "com.navi.medici.janus/lib"
|
||||
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@@ -17,5 +19,6 @@ func eventsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
lib.RequestChannel <- &lib.RequestObject{Body: body, Header: r.Header}
|
||||
io.WriteString(w, "ok")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@@ -28,16 +29,18 @@ func NewServer(port string) (*Server, error) {
|
||||
return nil, errors.Wrap(err, "failed to create listener")
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("/events", eventsHandler)
|
||||
// mux := http.NewServeMux()
|
||||
// mux.HandleFunc("/events", eventsHandler)
|
||||
// mux.HandleFunc("/events", eventshandler).Methods("POST")
|
||||
// mux.HandleFunc("/health", healthHandler).Methods("GET")
|
||||
// mux.HandleFunc("/health/toggle", healthToggleHandler).Methods("POST")
|
||||
// mux.HandleFunc("/refresh/schema", refreshSchemaHandler).Methods("POST")
|
||||
// mux.HandleFunc("/stop", stopHandler).Methods("POST")
|
||||
|
||||
httpServer := &http.Server{Addr: ":" + port, Handler: mux}
|
||||
router := mux.NewRouter()
|
||||
router.HandleFunc("/events", eventsHandler).Methods("POST")
|
||||
|
||||
httpServer := &http.Server{Addr: ":" + port, Handler: router}
|
||||
newServer := &Server{HttpServer: httpServer, Listener: listener}
|
||||
return newServer, nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user