Files
ophion/cmd/server/main.go
bigtux 5b662cf12f 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
2026-02-05 21:35:47 -03:00

66 lines
1.3 KiB
Go

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{}})
}