Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RestCmd = &cobra.Command{ Use: "rest", Short: "rest api", Run: func(cmd *cobra.Command, args []string) { dep := common.GetCommonDependency() defer dep.Logger.Sync() app := fiber.New() app.Use(recover.New(recover.Config{ Next: nil, EnableStackTrace: true, })) Router(dep, app) addr := fmt.Sprintf(":%d", dep.Config.App.Port) fmt.Printf("Server is listening on port %d\n", dep.Config.App.Port) go func() { if err := app.Listen(addr); err != nil && err != http.ErrServerClosed { dep.Logger.Fatal("shutting down the server") } }() quit := make(chan os.Signal, 1) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit dep.Logger.Info("Shutting down server...") ctx, shutdownCancel := context.WithTimeout(context.Background(), 30*time.Second) defer shutdownCancel() if err := app.ShutdownWithContext(ctx); err != nil { dep.Logger.Fatal("Server forced to shutdown: ", zap.Any("err", err.Error())) } dep.Logger.Info("Server exiting") }, }
RestCmd represents the rest command.
Functions ¶
func RouterSeven ¶
func RouterSeven(dep *common.RestDependency, router fiber.Router)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.