feat: refac and add key deletion route

This commit is contained in:
2026-04-29 14:46:24 +02:00
parent 8f6b1efea0
commit 6669fda371
11 changed files with 177 additions and 84 deletions
+32
View File
@@ -0,0 +1,32 @@
package routes
import (
"log/slog"
"orbits-server/internal/server/api/assets"
"orbits-server/internal/server/service"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
func RegisterCtrlRoutes(api *gin.RouterGroup, db *gorm.DB) {
ctrlService := service.NewControlService(db)
// define the control route on the api
// /api/control
ctrl := api.Group("/control")
// Display the information on what is going on at the moment
ctrl.GET("/command", func(c *gin.Context) {
command, err := ctrlService.ListLatestCommand()
if err != nil {
slog.Error("unable to determine state", "error", err)
assets.InternalErrorResponse(c)
return
}
assets.BasicResponse(c, command)
})
ctrl.PATCH("/command", func(c *gin.Context) {
})
}