feat: status api

This commit is contained in:
Ilia Denisov
2026-01-07 18:38:06 +02:00
parent 1b0ab7a079
commit 204d3df8cf
20 changed files with 188 additions and 40 deletions
+19
View File
@@ -1,12 +1,30 @@
package router
import (
"os"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
"github.com/iliadenisov/galaxy/internal/controller"
"github.com/iliadenisov/galaxy/internal/model/rest"
)
var (
StoragePath string
)
func init() {
StoragePath = os.Getenv("STORAGE_PATH")
}
func param() func(*controller.Param) {
return func(p *controller.Param) {
// TODO: initialize base controller settings
p.StoragePath = StoragePath
}
}
type Executor func(rest.Command) error
type Router struct {
@@ -35,6 +53,7 @@ func setupRouter(executor Executor) *gin.Engine {
v.RegisterValidation("notblank", notBlankStringValidator)
}
r.GET("/api/v1/status", StatusHandler)
r.PUT("/api/v1/command", LimitMiddleware(1), func(ctx *gin.Context) { CommandHandler(ctx, executor) })
return r
}