feat: status api
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user