1
0

Updated HttpServer in main.

This commit is contained in:
Alexander Andreev 2023-05-27 20:59:38 +04:00
parent 804d46f14e
commit f500cf945a
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -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)
}
} }