30 lines
546 B
Go
30 lines
546 B
Go
|
package web2
|
||
|
|
||
|
import (
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
"github.com/jinzhu/gorm"
|
||
|
"github.com/sirupsen/logrus"
|
||
|
)
|
||
|
|
||
|
type Server struct {
|
||
|
db *gorm.DB
|
||
|
log *logrus.Logger
|
||
|
router *fiber.App
|
||
|
}
|
||
|
|
||
|
// NewServer is a constructor for Server struct
|
||
|
// It takes a database connection and a logger as parameters
|
||
|
// It returns a pointer to a Server struct
|
||
|
func NewServer(db *gorm.DB, log *logrus.Logger) *Server {
|
||
|
app := fiber.New()
|
||
|
return &Server{
|
||
|
db: db,
|
||
|
log: log,
|
||
|
router: app,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (s *Server) Run() {
|
||
|
s.router.Listen(":3000")
|
||
|
}
|