Skip to content

JSON-formatted '/status' API response + generic cleanup#3038

Merged
ipspace merged 3 commits intodevfrom
api-cleanup
Jan 31, 2026
Merged

JSON-formatted '/status' API response + generic cleanup#3038
ipspace merged 3 commits intodevfrom
api-cleanup

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Jan 23, 2026

The /status API call can now return usable JSON data

@ipspace
Copy link
Owner Author

ipspace commented Jan 23, 2026

@sdargoeuves @captainpacket -- here's the API implementation of "netlab status" as a usable data structure.

I also did a bit of a cleanup, hopefully resulting in a more generic "get" method that can handle multiple multi-part requests.

I wanted to retain the "old" /status results in case anyone already uses them, so you get the JSON data structure back only with "/status/json" or "/status/json/instance". I would love to have a better idea how to handle that. Any suggestions?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSON-formatted responses to the /status API endpoint and refactors the API request handler routing logic for better maintainability.

Changes:

  • Added generic send_reply and send_error helper functions for consistent response handling
  • Enhanced /status endpoint to support JSON output and instance-specific queries
  • Refactored GET request routing to use separate handler dictionaries for simple and path-based endpoints
  • Updated default bind address to use external_commands.get_local_addr() instead of hardcoded localhost
  • Added KeyboardInterrupt handling and improved server startup logging with protocol information

The /status API call can now return usable JSON data
@ipspace ipspace marked this pull request as ready for review January 31, 2026 10:49
@ipspace ipspace requested a review from Copilot January 31, 2026 10:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

@ipspace
Copy link
Owner Author

ipspace commented Jan 31, 2026

I would love to have a better idea how to handle that. Any suggestions?

Lacking any better ideas, I went for the query string (having "json" in URL seemed awkward) with an environment variable as a fallback mechanism (and "json" as default). This allows an implementations to set an environment variable before starting the API server to keep using the old API format .

FYI @sdargoeuves @captainpacket

@ipspace ipspace merged commit 2661d6e into dev Jan 31, 2026
5 checks passed
@ipspace ipspace deleted the api-cleanup branch January 31, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant