update echo to v5 and prepare kontor-echo to use handlers, repository and service
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
"log"
|
||||
"log/slog"
|
||||
echojwt "github.com/labstack/echo-jwt/v4"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
)
|
||||
func main() {
|
||||
slog.Info("Kontor started")
|
||||
|
||||
db, err := schema.GetDatabase()
|
||||
|
||||
if err := config.InitConfig(); err != nil {
|
||||
log.Fatalf("Failed to initialize config: %v", err)
|
||||
}
|
||||
e := router.New(handlers.NewAdminHandler(db, config.ServerConfig.ApiSecret), handlers.NewMediaHandler(db))
|
||||
|
||||
// Cancel the context on SIGINT / SIGTERM
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
sc := echo.StartConfig{
|
||||
Address: ":1323",
|
||||
GracefulTimeout: 10 * time.Second,
|
||||
}
|
||||
if err := sc.Start(ctx, e); err != nil {
|
||||
e.Logger.Error("server stopped", "error", err)
|
||||
}
|
||||
|
||||
slog.Info("Kontor finished")
|
||||
}
|
||||
Reference in New Issue
Block a user