Updated HttpServer in main.
This commit is contained in:
parent
804d46f14e
commit
f500cf945a
@ -117,20 +117,19 @@ func main() {
|
|||||||
r.Handler(http.MethodPatch, "/api/mindflow/category/:id", mindflowApi.EditCategory)
|
r.Handler(http.MethodPatch, "/api/mindflow/category/:id", mindflowApi.EditCategory)
|
||||||
r.Handler(http.MethodDelete, "/api/mindflow/category/:id", mindflowApi.DeleteCategory)
|
r.Handler(http.MethodDelete, "/api/mindflow/category/:id", mindflowApi.DeleteCategory)
|
||||||
|
|
||||||
srv.POST("/api/mindflow-category", mindflowApi.NewCategory)
|
srv := dwhttp.NewHttpServer(r)
|
||||||
srv.PATCH("/api/mindflow-category/:id", mindflowApi.EditCategory)
|
|
||||||
srv.DELETE("/api/mindflow-category/:id", mindflowApi.DeleteCategory)
|
|
||||||
|
|
||||||
if err := srv.Start(network, *listenAddress); err != nil {
|
if err := srv.Start(network, *listenAddress); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := srv.Stop(); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
doneSignal := make(chan os.Signal, 1)
|
doneSignal := make(chan os.Signal, 1)
|
||||||
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
<-doneSignal
|
<-doneSignal
|
||||||
|
|
||||||
if err := srv.Stop(); err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user