mirror of
https://github.com/cubixle/tuu.git
synced 2026-04-30 14:08:44 +01:00
SAVEPOINT
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package tuu
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
@@ -12,11 +15,42 @@ type App struct {
|
||||
router Router
|
||||
}
|
||||
|
||||
func (a *App) Serve() {
|
||||
func (a *App) Serve() error {
|
||||
r := mux.NewRouter()
|
||||
|
||||
for _, route := range a.router.GetRoutes() {
|
||||
r.Handle(route.Path, route).Methods(route.Method)
|
||||
}
|
||||
|
||||
for _, route := range a.router.GetStaticRoutes() {
|
||||
r.PathPrefix(route.Path).Handler(route.Handler)
|
||||
}
|
||||
|
||||
server := http.Server{
|
||||
Addr: "",
|
||||
Handler: r,
|
||||
}
|
||||
|
||||
/*ctx, cancel := sigtx.WithCancel(a.Context, syscall.SIGTERM, os.Interrupt)
|
||||
defer cancel()
|
||||
|
||||
go func() {
|
||||
// gracefully shut down the application when the context is cancelled
|
||||
<-ctx.Done()
|
||||
fmt.Println("Shutting down application")
|
||||
|
||||
err := a.Stop(ctx.Err())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
err = server.Shutdown(ctx)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
}()*/
|
||||
|
||||
// start the web server
|
||||
return server.ListenAndServe()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user