X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-mediator-producer%2Finternal%2Fserver%2Fserver.go;h=0b5e5b8c9c6befc2c5ff84f1967d147b298e9afd;hb=fc15c05eeaedbb68fd58b7387ff707bd23f49eef;hp=c3a1331cabc1f779495ae1971d9f29d335ae5090;hpb=63a42cacf9c52b7dff64431a3354f55c49bd6e4b;p=nonrtric.git diff --git a/dmaap-mediator-producer/internal/server/server.go b/dmaap-mediator-producer/internal/server/server.go index c3a1331c..0b5e5b8c 100644 --- a/dmaap-mediator-producer/internal/server/server.go +++ b/dmaap-mediator-producer/internal/server/server.go @@ -29,8 +29,11 @@ import ( "oransc.org/nonrtric/dmaapmediatorproducer/internal/jobs" ) +const StatusCallbackPath = "/status" +const JobsCallbackPath = "/jobs" + func StatusHandler(w http.ResponseWriter, r *http.Request) { - if r.URL.Path != "/" { + if r.URL.Path != StatusCallbackPath { http.Error(w, "404 not found.", http.StatusNotFound) return } @@ -44,7 +47,7 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) { } func CreateInfoJobHandler(w http.ResponseWriter, r *http.Request) { - if r.URL.Path != "/producer_simulator/info_job" { + if r.URL.Path != JobsCallbackPath { http.Error(w, "404 not found.", http.StatusNotFound) return } @@ -68,14 +71,3 @@ func CreateInfoJobHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprintf("Invalid job info. Cause: %v", err), http.StatusBadRequest) } } - -func CreateServer(port int, handlerFunc func(http.ResponseWriter, *http.Request)) *http.Server { - - mux := http.NewServeMux() - mux.HandleFunc("/", handlerFunc) - server := http.Server{ - Addr: fmt.Sprintf(":%v", port), // :{port} - Handler: mux, - } - return &server -}