chore: more scaffolding
This commit is contained in:
@@ -42,3 +42,7 @@ func init() {
|
||||
nodes := loadEnv("NODES", "") // for example "node1,node2,node3"
|
||||
Nodes = strings.Split(nodes, ",")
|
||||
}
|
||||
|
||||
func IsModeDevelopment() bool {
|
||||
return strings.HasPrefix(strings.ToLower(Mode), "dev")
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func (r *Router) Api(api fiber.Router) {
|
||||
func (r *Service) Api(api fiber.Router) {
|
||||
api.Get("/status", func(c *fiber.Ctx) error {
|
||||
return c.JSON("ok")
|
||||
})
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
)
|
||||
|
||||
const FrontendOutDir = "./out/frontend"
|
||||
|
||||
func (s *Service) Root(r fiber.Router) {
|
||||
|
||||
r.Use(logger.New())
|
||||
r.Use(recover.New())
|
||||
|
||||
r.Static("/", FrontendOutDir)
|
||||
|
||||
for _, entrypoint := range HtmlEntrypoints {
|
||||
r.Get(entrypoint.Route, func(c *fiber.Ctx) error {
|
||||
return c.SendFile(path.Join(FrontendOutDir, entrypoint.Filename))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package routes
|
||||
import "git.phc.dm.unipi.it/phc/cluster-dashboard/backend/database"
|
||||
|
||||
// Router is the main service that defines all routes, this only depends on the Database service
|
||||
type Router struct {
|
||||
type Service struct {
|
||||
Database database.Database
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user