31 lines
443 B
Go
31 lines
443 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"onyx-api/internal/config"
|
||
|
|
||
|
"github.com/labstack/echo/v4"
|
||
|
)
|
||
|
|
||
|
var err error
|
||
|
|
||
|
type Server struct {
|
||
|
router *echo.Echo
|
||
|
config *config.Config
|
||
|
}
|
||
|
|
||
|
func NewServer(cfg *config.Config) *Server {
|
||
|
return &Server{config: cfg, router: echo.New()}
|
||
|
}
|
||
|
|
||
|
func (s *Server) Run() error {
|
||
|
err = s.router.Start(":" + s.config.AppPortListen)
|
||
|
if err != nil {
|
||
|
log.Printf("Error starting Server")
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|