mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update logger
This commit is contained in:
@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/usememos/memos/plugin/telegram"
|
||||
@ -49,31 +48,15 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
||||
telegramBot: telegram.NewBotWithHandler(integration.NewTelegramHandler(store)),
|
||||
}
|
||||
|
||||
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||
Format: `{"time":"${time_rfc3339}","latency":"${latency_human}",` +
|
||||
`"method":"${method}","uri":"${uri}",` +
|
||||
`"status":${status},"error":"${error}"}` + "\n",
|
||||
}))
|
||||
|
||||
// Register CORS middleware.
|
||||
e.Use(CORSMiddleware())
|
||||
|
||||
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
||||
Skipper: grpcRequestSkipper,
|
||||
Timeout: 30 * time.Second,
|
||||
}))
|
||||
|
||||
serverID, err := s.getSystemServerID(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to retrieve system server ID")
|
||||
}
|
||||
s.ID = serverID
|
||||
|
||||
// Only serve frontend when it's enabled.
|
||||
if profile.Frontend {
|
||||
frontendService := frontend.NewFrontendService(profile, store)
|
||||
frontendService.Serve(ctx, e)
|
||||
}
|
||||
|
||||
secret := "usememos"
|
||||
if profile.Mode == "prod" {
|
||||
secret, err = s.getSystemSecretSessionName(ctx)
|
||||
@ -88,6 +71,12 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
||||
return c.String(http.StatusOK, "Service ready.")
|
||||
})
|
||||
|
||||
// Only serve frontend when it's enabled.
|
||||
if profile.Frontend {
|
||||
frontendService := frontend.NewFrontendService(profile, store)
|
||||
frontendService.Serve(ctx, e)
|
||||
}
|
||||
|
||||
// Register API v1 endpoints.
|
||||
rootGroup := e.Group("")
|
||||
apiV1Service := apiv1.NewAPIV1Service(s.Secret, profile, store, s.telegramBot)
|
||||
|
Reference in New Issue
Block a user