feat: Initial OPHION structure
- Go backend with Fiber framework - Agent for metrics collection - Docker Compose for self-hosted - Auth middleware (JWT + API Keys) - Rate limiting - Install script
This commit is contained in:
65
cmd/server/main.go
Normal file
65
cmd/server/main.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := fiber.New(fiber.Config{
|
||||
AppName: "OPHION Observability Platform",
|
||||
})
|
||||
|
||||
// Middleware
|
||||
app.Use(logger.New())
|
||||
app.Use(cors.New())
|
||||
|
||||
// Health check
|
||||
app.Get("/health", func(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{
|
||||
"status": "healthy",
|
||||
"service": "ophion",
|
||||
"version": "0.1.0",
|
||||
})
|
||||
})
|
||||
|
||||
// API routes
|
||||
api := app.Group("/api/v1")
|
||||
api.Get("/metrics", getMetrics)
|
||||
api.Post("/metrics", ingestMetrics)
|
||||
api.Get("/logs", getLogs)
|
||||
api.Post("/logs", ingestLogs)
|
||||
api.Get("/alerts", getAlerts)
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
}
|
||||
|
||||
log.Printf("🐍 OPHION starting on port %s", port)
|
||||
log.Fatal(app.Listen(":" + port))
|
||||
}
|
||||
|
||||
func getMetrics(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"metrics": []string{}})
|
||||
}
|
||||
|
||||
func ingestMetrics(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"status": "received"})
|
||||
}
|
||||
|
||||
func getLogs(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"logs": []string{}})
|
||||
}
|
||||
|
||||
func ingestLogs(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"status": "received"})
|
||||
}
|
||||
|
||||
func getAlerts(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"alerts": []string{}})
|
||||
}
|
||||
Reference in New Issue
Block a user