Repository navigation
feat(cli): send --dry-run, preview a request with secrets redacted - #109
Merged
Merged
Conversation
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.
Adds
apic send --dry-run. It prints the requestsendwould build and sends nothing. Every variable that has a value is shown as$nameinstead of its value, so agents and logs can see what will hit the server without seeing secrets from.apic/env/*.local.toml.Behaviour
Target:is the real scheme, host and port, with anyuser:pass@removed.sendwould, with the same message: an unfilled{id}, a non-http URL, or a missing file part.prepare's order. AContent-Typethatprepareadds itself shows its real value.--jsonprints{"dry_run": true, "method", "target", "url", "headers", "body", "undefined"}, pluspartsfor a multipart body.--dry-runconflicts with-i. A dry run exits 0, 1, 2 or 3 assenddoes, and never 4.Implementation
apic-coregainshttp::previewand its typesPreview,PreviewBodyandPartPreview. It callspreparefor the refusals and the real target, then rebuilds the URL, headers and body with each defined name mapped to$name. The URL, query and header steps ofpreparemoved into private helpers that both functions use, andprepare's output is unchanged.Tests
Previewdebug output; header parity withprepare; parts without bytes; refusals matchingprepare; and undefined-name collection.--dry-run -i, and an unfilled path param.cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo testandcargo test -p apic-coreall pass.Note
A value written
${tok}xpreviews as$tokx.Docs:
SENDING.md(new "Dry run" section) andCOMMAND.md. The apic-web mirror is a separate PR.