Initial commit
This commit is contained in:
43
internal/app/api/v1/router.go
Normal file
43
internal/app/api/v1/router.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"git.cesium.pw/niku/virteen/internal/auth"
|
||||
"git.cesium.pw/niku/virteen/internal/middleware"
|
||||
"git.cesium.pw/niku/virteen/internal/podman"
|
||||
"git.cesium.pw/niku/virteen/internal/podman/models"
|
||||
"git.cesium.pw/niku/virteen/internal/podman/services"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/monitor"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func ConfigureRoutes(router fiber.Router) error {
|
||||
v1 := router.Group("/v1")
|
||||
|
||||
ac := auth.NewPamAuthController()
|
||||
ag := v1.Group("/auth")
|
||||
ag.Post("/token", ac.GetToken)
|
||||
|
||||
v1.Get("/ping", Ping)
|
||||
v1.Get("/metrics", monitor.New())
|
||||
|
||||
v1.Use(middleware.Protected())
|
||||
|
||||
var cs models.PodmanService
|
||||
cs, err := services.NewPodmanContainerService()
|
||||
if err != nil {
|
||||
panic(errors.Wrapf(err, "failed to build podman container service"))
|
||||
}
|
||||
|
||||
cc := podman.NewPodmanController(&cs)
|
||||
|
||||
cg := v1.Group("/containers")
|
||||
cg.Get("/", cc.ListContainers)
|
||||
cg.Post("/", cc.CreateContainer)
|
||||
|
||||
ccg := cg.Group("/:name")
|
||||
ccg.Put("/status", cc.UpdateContainerStatus)
|
||||
ccg.Delete("/", cc.DeleteContainer)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user