1
0
Bifurcation 0
Ce dépôt a été archivé le 2024-03-02. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
mangadex-next/main.go
2021-03-21 18:40:39 +00:00

47 lignes
1,1 Kio
Go

package main
import (
"log"
"net/http"
"os"
"time"
"github.com/getsentry/sentry-go"
"github.com/gorilla/mux"
"github.com/hbjydev/mangadex-next/database"
"github.com/hbjydev/mangadex-next/middlewares"
"github.com/hbjydev/mangadex-next/routers"
)
func main() {
if os.Getenv("SENTRY_DSN") != "" {
err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
Environment: os.Getenv("SENTRY_ENV"),
Release: os.Getenv("SENTRY_RELEASE"),
AttachStacktrace: true,
Debug: true,
})
if err != nil {
log.Fatalf("Error initializing Sentry integration: %v", err)
}
defer sentry.Flush(2 * time.Second)
}
log.Println("Starting Mangadex API service...")
log.Println("Connecting to database...")
database.Connect()
log.Println("Connected!")
r := mux.NewRouter()
r.Use(middlewares.LogMiddleware)
r.Use(middlewares.SentryMiddleware)
healthRouter := routers.HealthRouter{}
healthRouter.RegisterRoutes(r)
log.Println("Starting server on :3000...")
log.Fatal(http.ListenAndServe(":3000", r))
}