feat: Sentinela v0.2.0 — Brazilian Financial Data API in Go
- 20 Go source files, single 16MB binary - SQLite + FTS5 full-text search (pure Go, no CGO) - BCB integration: Selic, CDI, IPCA, USD/BRL, EUR/BRL - CVM integration: 2,524 companies from registry - Fiber v2 REST API with 42 handlers - Auto-seeds on first run (~5s for BCB + CVM) - Token bucket rate limiter, optional API key auth - Periodic sync scheduler (configurable) - Graceful shutdown, structured logging (slog) - All endpoints tested with real data
This commit is contained in:
23
internal/api/handlers/search.go
Normal file
23
internal/api/handlers/search.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func (h *Handler) GlobalSearch(c *fiber.Ctx) error {
|
||||
q := c.Query("q")
|
||||
if q == "" {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "query parameter 'q' required"})
|
||||
}
|
||||
limit, _ := strconv.Atoi(c.Query("limit", "10"))
|
||||
|
||||
companies, _ := h.db.SearchCompanies(q, limit)
|
||||
filings, _ := h.db.SearchFilings(q, limit)
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"companies": fiber.Map{"data": companies, "total": len(companies)},
|
||||
"filings": fiber.Map{"data": filings, "total": len(filings)},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user