package routes import ( "fmt" "github.com/gofiber/fiber/v2" ) func (r *Router) ApiMonitor(api fiber.Router) { // Respond to requests like // - "/api/monitor/status?script=SCRIPT_NAME" where SCRIPT_NAME is the name of a file inside "./scripts" api.Get("/status", func(c *fiber.Ctx) error { if qScript := c.Query("script"); qScript != "" { output, err := r.Monitor.GetOutput(qScript) if err != nil { return err } return c.JSON(output) } return fmt.Errorf("no script, device or entity provided") }) }