feat(serve): complete REST API server and add --url flag#384
Merged
Conversation
…onnections Refactor `boxlite serve` from a partial implementation into a complete REST API server compatible with the `Boxlite.rest()` client, and add `--url` CLI flag so all commands can operate against a remote server. Server changes: - Split monolithic serve.rs into module directory with dedicated handlers - Fix route prefix from /v1/local/ to /v1/default/ (matching client expectation) - Add OAuth endpoint (POST /v1/oauth/tokens) for client authentication - Add execution control endpoints (input, signal, resize, status) - Add file transfer (PUT/GET tar-based upload/download) - Add metrics endpoints (runtime and per-box) - Add snapshot CRUD and restore endpoints - Add clone, export, and import endpoints - Fix config response format to return capabilities CLI changes: - Add --url flag (also reads BOXLITE_REST_URL env var) to GlobalFlags - Enable rest feature on boxlite dependency - When --url is set, create_runtime() returns REST-backed runtime - All 14 CLI commands automatically work against remote server Also fix REST API example to use default serve port (8100) and fix test_images_format to handle empty image list (returns [] with no images).
2 tasks
lilongen
pushed a commit
to lilongen/boxlite
that referenced
this pull request
Jun 2, 2026
Make copy_in/copy_out over REST behave identically to the local backend (docker-cp semantics), with the local backend as the reference. - REST client (rest/litebox.rs): honor CopyOptions instead of dropping them — overwrite rides a PUT query param, include_parent/follow_symlinks a GET query param; pack/extract via boxlite_shared::tar (the bespoke create_tar_from_path is gone). Fail-fast on an empty path, mirroring the local backend's guard + ordering. Fixes F-010: box->host now extracts a single file to the exact path instead of unpacking the raw tar into a freshly-created directory. - serve (serve/handlers/files.rs): faithful temp-dir bridge — stage_upload_tar + copy_into(include_parent:false) removes the historical 'extracted/' leak (boxlite-ai#384); download success response built infallibly via into_response(). - serve types: FileQuery carries optional overwrite/include_parent/ follow_symlinks query params, defaulting to docker-cp defaults. - CLI: --include-parent (presence-only, unsettable) -> --no-include-parent. - lib.rs re-exports boxlite_shared::tar; serde_urlencoded dev-dep for the FileQuery parse test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
boxlite serveinto a complete REST API server compatible with theBoxlite.rest()client--urlCLI flag (andBOXLITE_REST_URLenv var) so all CLI commands can operate against a remote servertest_images_formattest failure (empty image list returns[])Server changes
serve.rsinto module directory with 8 dedicated handler files/v1/local/to/v1/default/(matching client expectation)POST /v1/oauth/tokens)CLI changes
--urlglobal flag to connect to a remoteboxlite serveinstancerestfeature onboxlitedependencyTest plan
cargo clippy -p boxlite-cli --tests -- -D warningspassescargo fmt -p boxlite-cli --checkpassestest_images_format)boxlite serve --port 8100+boxlite --url http://localhost:8100 listpython examples/python/08_rest_api/run_commands.pyagainstboxlite serve