Checkpoint
Some checks failed
Test and build / Test and lint (push) Failing after 36s
Test and build / Build collector (push) Failing after 43s
Test and build / Build receiver (push) Failing after 42s

This commit is contained in:
2026-03-05 15:38:18 +01:00
parent 3106b2cf45
commit 13afa08e8a
108 changed files with 19509 additions and 729 deletions

65
server/handlers_aprs.go Normal file
View File

@@ -0,0 +1,65 @@
package server
import (
"net/http"
"strconv"
"github.com/labstack/echo/v4"
"git.maze.io/ham/hamview/schema"
)
// handleGetAPRSPackets returns APRS packets based on filter criteria.
//
// Endpoint: GET /api/v1/aprs/packets
//
// Query Parameters (evaluated in order):
// - src: APRS source callsign (case-insensitive)
// - dst: APRS destination callsign (case-insensitive)
// - limit: Maximum number of recent packets (default: 100)
// - (no parameters): Returns the 100 most recent packets
//
// Response: 200 OK
//
// []APRSPacket - Array of APRS packet objects
//
// Response: 500 Internal Server Error
//
// ErrorResponse - Error retrieving packets
//
// Example Requests:
//
// GET /api/v1/aprs/packets
// GET /api/v1/aprs/packets?src=OE1ABC
// GET /api/v1/aprs/packets?dst=APRS
// GET /api/v1/aprs/packets?limit=200
func (s *Server) handleGetAPRSPackets(c echo.Context) error {
var (
ctx = c.Request().Context()
packets []*schema.APRSPacket
err error
)
if source := c.QueryParam("src"); source != "" {
packets, err = schema.GetAPRSPacketsBySource(ctx, source)
} else if destination := c.QueryParam("dst"); destination != "" {
packets, err = schema.GetAPRSPacketsByDestination(ctx, destination)
} else {
limit := 100
if value := c.QueryParam("limit"); value != "" {
if limit, err = strconv.Atoi(value); err != nil {
return s.apiError(c, err)
}
}
if limit <= 0 {
limit = 100
}
packets, err = schema.GetAPRSPackets(ctx, limit)
}
if err != nil {
return s.apiError(c, err)
}
return c.JSON(http.StatusOK, packets)
}