41 lines
923 B
Go
41 lines
923 B
Go
package httpserver
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
notificationservice "github.com/SamuelTariku/FortuneBet-Backend/internal/services/notfication"
|
|
"github.com/bytedance/sonic"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type App struct {
|
|
fiber *fiber.App
|
|
NotidicationStore notificationservice.NotificationStore
|
|
port int
|
|
Logger *slog.Logger
|
|
}
|
|
|
|
func NewApp(port int, logger *slog.Logger, notidicationStore notificationservice.NotificationStore) *App {
|
|
app := fiber.New(fiber.Config{
|
|
CaseSensitive: true,
|
|
DisableHeaderNormalizing: true,
|
|
JSONEncoder: sonic.Marshal,
|
|
JSONDecoder: sonic.Unmarshal,
|
|
})
|
|
s := &App{
|
|
fiber: app,
|
|
port: port,
|
|
NotidicationStore: notidicationStore,
|
|
Logger: logger,
|
|
}
|
|
|
|
s.initAppRoutes()
|
|
|
|
return s
|
|
}
|
|
|
|
func (a *App) Run() error {
|
|
return a.fiber.Listen(fmt.Sprintf(":%d", a.port))
|
|
}
|