Commit 22ad96331a

22ad96331a4456662f740c48882cab8aadd6d0b4

parent: 5fe3aeb2ce

Unsigned

cmc <hello@cleberg.net> · 2026-07-24 23:46 UTC

feat: add Copy cURL Command button to the Local API page (#30)

Adds a one-tap way to get a working, authenticated request from the Local
API settings page. copyCurlCommand() copies a curl invocation using the
current bound address and token via the Authorization header:

  curl -H "Authorization: Bearer <token>" http://127.0.0.1:<port>/portfolio

Keeps the token in a header rather than a query string, so it stays out of
URLs, browser history, and the request-log view (which masks the token).
Guards on an empty token, matching copyToken().

Layout: unified · split

DomainDig/ContentView.swift +4
@@ -3029,6 +3029,10 @@ private struct LocalAPISettingsView: View {
30293029 localAPIService.copyToken()
30303030 }
30313031
3032 Button("Copy cURL Command") {
3033 localAPIService.copyCurlCommand()
3034 }
3035
30323036 Button("Rotate Token") {
30333037 localAPIService.rotateToken()
30343038 }
LocalAPIService.swift +5
@@ -142,6 +142,11 @@ final class LocalAPIService {
142142 AppClipboard.copy(config.token)
143143 }
144144
145 func copyCurlCommand() {
146 guard !config.token.isEmpty else { return }
147 AppClipboard.copy("curl -H \"Authorization: Bearer \(config.token)\" \(address)/portfolio")
148 }
149
145150 func localSecretReferences() -> [String] {
146151 [LocalAPISecretStore.reference]
147152 }