Yimaru-BackEnd/internal/web_server/app.go
2025-03-28 00:00:03 +03:00

35 lines
531 B
Go

package httpserver
import (
"fmt"
"github.com/bytedance/sonic"
"github.com/gofiber/fiber/v2"
)
type App struct {
fiber *fiber.App
port int
}
func NewApp(port int) *App {
app := fiber.New(fiber.Config{
CaseSensitive: true,
DisableHeaderNormalizing: true,
JSONEncoder: sonic.Marshal,
JSONDecoder: sonic.Unmarshal,
})
s := &App{
fiber: app,
port: port,
}
s.initAppRoutes()
return s
}
func (a *App) Run() error {
return a.fiber.Listen(fmt.Sprintf(":%d", a.port))
}