feat(http/api): full http api expansion (config, status, bedrock players, lite routing)#570
feat(http/api): full http api expansion (config, status, bedrock players, lite routing)#570dilllxd wants to merge 8 commits intominekube:masterfrom
Conversation
…ck player data, and lite features!
robinbraemer
left a comment
There was a problem hiding this comment.
Left some comments. Didn’t looked at api implementation yet since that likely changes
Sounds good, will look into later and resolve. |
Review Writeup🔧 L51 - Lite Mode InconsistencyIssue: "The servers and players fields would be inconsistent when in lite mode." ✅ Solution: Complete redesign of status API
🔐 L56 - Secret RedactingIssue: "Which secrets?" ✅ Solution: Removed all secret redacting functionality
🏗️ L66 - Service SeparationIssue: "All Lite RPCs would be better in a dedicated GateLiteService." ✅ Solution: Created separate service for lite operations
📝 L123 - DisconnectPlayerRequest Comment FormattingIssue: "Be careful why did this got formatted" ✅ Solution: Reverted accidental escape formatting
🎮 L237, L244, L499 - Enum ImplementationIssues:
✅ Solution: Implemented proper enums for all identified fields
📝 L270 - Config API SimplificationIssue: "Since json is a superset of yaml I would be curious to drop this and always parse the config input with a yaml decoder. Or auto detect json/yaml… As long as we can simplify the api." ✅ Solution: Eliminated ConfigFormat enum, simplified to single field
🗑️ L285 - Obsolete Code RemovalIssue: "This health service is obsolete code in gate." ✅ Solution: Removed HealthServiceConfig entirely
📖 L315 - Documentation CoverageIssue: "I'm missing doc comments above the fields. That goes with all fields in the PR." ✅ Solution: Added comprehensive field documentation
🔧 L344 - StringList Helper RemovalIssue: "Not sure what the real benefit is." ✅ Solution: Removed StringList helper, simplified approach
|
New API Docs:🟢 Status Checkcurl -X POST http://localhost:8080/minekube.gate.v1.GateService/GetStatus \
-H 'Content-Type: application/json' \
-d '{}'Example Response (Classic Mode) {
"version": "0.57.0",
"mode": "PROXY_MODE_CLASSIC",
"classic": {
"players": 5,
"servers": 3
}
}Example Response (Lite Mode) {
"version": "0.57.0",
"mode": "PROXY_MODE_LITE",
"lite": {
"connections": 12,
"routes": 2
}
}
📑 Validate Config (YAML / JSON)YAML Example curl -X POST http://localhost:8080/minekube.gate.v1.GateService/ValidateConfig \
-H 'Content-Type: application/json' \
-d '{
"config": "api:\n enabled: true\n bind: localhost:8080\n\nconfig:\n bind: 0.0.0.0:25565\n onlineMode: true\n forwarding:\n mode: legacy\n servers:\n server1: localhost:25566\n try:\n - server1"
}'JSON Example curl -X POST http://localhost:8080/minekube.gate.v1.GateService/ValidateConfig \
-H 'Content-Type: application/json' \
-d '{
"config": "{\"api\":{\"enabled\":true,\"bind\":\"localhost:8080\"},\"config\":{\"bind\":\"0.0.0.0:25565\",\"onlineMode\":true,\"forwarding\":{\"mode\":\"legacy\"},\"servers\":{\"server1\":\"localhost:25566\"},\"try\":[\"server1\"]}}"
}'Example Response {
"warnings": [],
"errors": []
}
⚙️ Apply ConfigIn-Memory curl -X POST http://localhost:8080/minekube.gate.v1.GateService/ApplyConfig \
-H 'Content-Type: application/json' \
-d '{
"config": "api:\n enabled: true\n bind: localhost:8080\n\nconfig:\n bind: 0.0.0.0:25565\n onlineMode: true\n forwarding:\n mode: legacy\n servers:\n server1: localhost:25566\n try:\n - server1",
"persist": false
}'Persistent curl -X POST http://localhost:8080/minekube.gate.v1.GateService/ApplyConfig \
-H 'Content-Type: application/json' \
-d '{
"config": "api:\n enabled: true\n bind: localhost:8080\n\nconfig:\n bind: 0.0.0.0:25565\n onlineMode: true\n forwarding:\n mode: legacy\n servers:\n server1: localhost:25566\n try:\n - server1",
"persist": true
}'Example Response {
"warnings": ["config persisted to disk"]
}📂 Get Current Configcurl -X POST http://localhost:8080/minekube.gate.v1.GateService/GetConfig \
-H 'Content-Type: application/json' \
-d '{}'Example Response {
"payload": "api:\n enabled: true\n bind: localhost:8080\n\nconfig:\n bind: 0.0.0.0:25565\n onlineMode: true\n forwarding:\n mode: legacy\n servers:\n lobby: localhost:25565\n try:\n - lobby\n lite:\n enabled: false\n routes: []"
}
👥 Player ManagementList Players curl -X POST http://localhost:8080/minekube.gate.v1.GateService/ListPlayers \
-H 'Content-Type: application/json' \
-d '{}' | jqGet Player (with Bedrock Data) curl -X POST http://localhost:8080/minekube.gate.v1.GateService/GetPlayer \
-H 'Content-Type: application/json' \
-d '{"username": ".BedrockPlayer"}'Example Response {
"player": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": ".BedrockPlayer",
"bedrock": {
"xuid": 2533274792395724,
"deviceOs": "BEDROCK_DEVICE_OS_ANDROID",
"language": "en_US",
"uiProfile": "BEDROCK_UI_PROFILE_POCKET",
"inputMode": "BEDROCK_INPUT_MODE_TOUCH",
"behindProxy": false,
"linkedPlayer": "JavaAccount123"
}
}
}
🛠️ Lite Route ManagementList Lite Routes curl -X POST http://localhost:8080/minekube.gate.v1.GateLiteService/ListLiteRoutes \
-H 'Content-Type: application/json' \
-d '{}' | jqExample Response {
"routes": [
{
"hosts": ["mc.example.com"],
"backends": [
{ "address": "127.0.0.1:25570", "activeConnections": 5 }
],
"strategy": "LITE_ROUTE_STRATEGY_SEQUENTIAL",
"options": {
"proxyProtocol": false,
"tcpShieldRealIp": false,
"modifyVirtualHost": true,
"cachePingTtlMs": 10000
}
}
]
}Add Lite Backend curl -X POST http://localhost:8080/minekube.gate.v1.GateLiteService/AddLiteRouteBackend \
-H 'Content-Type: application/json' \
-d '{"host": "mc.example.com", "backend": "127.0.0.1:25570"}'Remove Lite Backend curl -X POST http://localhost:8080/minekube.gate.v1.GateLiteService/RemoveLiteRouteBackend \
-H 'Content-Type: application/json' \
-d '{"host": "mc.example.com", "backend": "127.0.0.1:25570"}'Update Lite Strategy curl -X POST http://localhost:8080/minekube.gate.v1.GateLiteService/UpdateLiteRouteStrategy \
-H 'Content-Type: application/json' \
-d '{"host": "mc.example.com", "strategy": "LITE_ROUTE_STRATEGY_LEAST_CONNECTIONS"}'Update Lite Options curl -X POST http://localhost:8080/minekube.gate.v1.GateLiteService/UpdateLiteRouteOptions \
-H 'Content-Type: application/json' \
-d '{
"host": "mc.example.com",
"options": {
"proxyProtocol": true,
"cachePingTtlMs": 20000
},
"updateMask": {
"paths": ["proxy_protocol", "cache_ping_ttl_ms"]
}
}'Update Lite Fallback curl -X POST http://localhost:8080/minekube.gate.v1.GateLiteService/UpdateLiteRouteFallback \
-H 'Content-Type: application/json' \
-d '{
"host": "mc.example.com",
"fallback": {
"motdJson": "\"Temporarily Offline\"",
"version": { "name": "Gate Lite", "protocol": 764 },
"players": { "online": 0, "max": 100 }
},
"updateMask": {
"paths": ["motd_json", "version", "players"]
}
}' |
Introduces pkg/gate/api_handlers.go implementing config and lite route management via API, including config persistence and route updates. Updates API setup to pass config file path, extends Options and Gate initialization for config persistence, and registers GateLiteService handler in the API server. Also updates service.go to implement GateLiteServiceHandler interface.
Files ModifiedCore Changes
API Infrastructure Fixes
Build/Development
Key Implementation Details
API Handler FeaturesThe new
|
robinbraemer
left a comment
There was a problem hiding this comment.
Next quest would be to add tests to this baby to make sure this massive PR works
On it, will make the two changes you requested then work on tests. |
Test Coverage for HTTP API ExpansionOverviewAdded comprehensive test coverage for the HTTP API expansion feature, ensuring all new functionality is thoroughly tested and follows Gate's established testing patterns. New Test Files Added1.
|
Accidentally added this to commit
|
Currently a bit overloaded by volume of this PR so will take longer :) |
Fixes a race condition where config reload events were being fired while holding the mutex lock. This moves the reload.FireConfigUpdate calls outside the critical section in both ConfigHandlerImpl.ApplyConfig and LiteHandlerImpl.applyConfigUpdate methods. Also adds routes field to GetStatus response for lite mode configuration.
|
@cursor can you run the tests to check if they not block forever. Also provide tips to make the PR cleaner it looks a bit bloated and incomplete (hard to review) also regarding what futures it adds, and describe the value-add/use cases. Maybe also update our .web/docs for our users in the http api sections |
Summary
This PR delivers a major expansion of the Gate HTTP API, enabling full lifecycle config management, bedrock player insights, and dynamic Lite route operations.
Changes Made
🟢 Status RPC
GetStatusendpoint for lightweight health/metadata checks🔧 Config Management
"persist": true) to overwrite existing config file while preserving original format (YAML/JSON)oneofdesign: choosejson_config(structured, snake_case) oryaml_config(string, camelCase)🎮 Player Management
bedrocksub-object for cross-play users, including:🌐 Lite Route Management
least-connections,round-robin)🧪 Testing & Quality
API Examples
Status Check
Example Response
{ "version": "0.57.0", "mode": "standard", "players_online": 5, "servers_registered": 3 }Validate Config (JSON)
Example Response
{ "valid": true, "warnings": [] }Apply Config (In-Memory)
Example Response
{ "applied": true, "persisted": false }Apply Config (Persistent, YAML)
Example Response
{ "applied": true, "persisted": true }List Players
Example Response
{ "players": [ { "id": "uuid-1", "username": "Steve" }, { "id": "uuid-2", "username": ".BedrockPlayer" } ] }Get Player (with Bedrock Data)
Example Response
{ "player": { "id": "550e8400-e29b-41d4-a716-446655440000", "username": ".BedrockPlayer", "bedrock": { "xuid": 2533274792395724, "device_os": "Android", "language": "en_US", "ui_profile": 1, "input_mode": 2, "behind_proxy": false, "linked_player": "JavaAccount123" } } }List Lite Routes
Example Response
{ "routes": [ { "host": "mc.example.com", "backends": ["127.0.0.1:25570"] } ] }Add Lite Backend
Example Response
{ "success": true }Remove Lite Backend
Example Response
{ "success": true }Update Lite Strategy
Example Response
{ "updated": true }Update Lite Options
Example Response
{ "updated": true }Update Lite Fallback
Example Response
{ "updated": true }Attribution
This PR was prepared with assistance from Codex & Claude Code. All code changes were reviewed by the author.