Add JSON validation middleware to ensure valid API responses

- Created JSONValidationMiddleware that validates all JSON responses
- Ensures that even on timeout or internal errors, a valid JSON error response is returned
- Applied to all API endpoints including /status.json
- Prevents client-side JSON parse errors when server encounters issues
This commit is contained in:
2025-07-29 04:13:01 +02:00
parent 7aec01c499
commit 3338e92785
4 changed files with 1840812 additions and 1487242 deletions

View File

@@ -1482,6 +1482,7 @@ func (d *Database) GetASPeersContext(ctx context.Context, asn int) ([]ASPeer, er
err := rows.Scan(&peer.ASN, &peer.Handle, &peer.Description, &peer.FirstSeen, &peer.LastSeen)
if err != nil {
d.logger.Error("Failed to scan peer row", "error", err, "asn", asn)
continue
}
peers = append(peers, peer)