Skip to content

Commit

Permalink
CLI: remove --no-logging flag
Browse files Browse the repository at this point in the history
The `listen` command at one point supported a mode where it would skip
logging requests in Play's UI.

Today, this doesn't seem to be supported (Play rejects the request
because it says the token is invalid).

Rather than work to repair this in Play, we're just going to remove the
flag.
  • Loading branch information
svix-onelson committed Dec 31, 2024
1 parent 280476b commit 9f1cceb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
4 changes: 2 additions & 2 deletions svix-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ Webhook Relay is now listening at:
https://play.svix.com/in/c_tSdQhb4Q5PTF5m2juiWu8qFREqE/

All requests on this endpoint will be forwarded to your local URL:
http://localhost:8000/webhook/
http://localhost:8080/webhook/

View logs and debug information at:
https://play.svix.com/view/c_tSdQhb4Q5PTF5m2juiWu8qFREqE/
To disable logging, run `svix-cli listen --no-logging`
```

The above command will return you a unique URL and forward any POST requests it receives
Expand Down
4 changes: 0 additions & 4 deletions svix-cli/src/cmds/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::config::{get_config_file_path, Config};
pub struct ListenArgs {
/// The local URL to forward webhooks to
url: url::Url,
/// Disables History Logging
#[clap(long)]
no_logging: bool,
}

impl ListenArgs {
Expand All @@ -34,7 +31,6 @@ impl ListenArgs {
crate::relay::listen(
self.url,
token,
!self.no_logging,
cfg.relay_debug_hostname.as_deref(),
cfg.relay_disable_security.unwrap_or_default(),
)
Expand Down
35 changes: 8 additions & 27 deletions svix-cli/src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ struct Client {
websocket_url: url::Url,
local_url: url::Url,
http_client: HttpClient,
logging: bool,
}

/// Special handling for the errors during establishing a websocket connection.
Expand Down Expand Up @@ -166,29 +165,21 @@ impl Client {
if show_welcome_message {
printdoc!(
r#"
Webhook Relay is now listening at:
{}
All requests on this endpoint will be forwarded to your local URL:
{}
View logs and debug information at:
{}
"#,
receive_url(&start_response.token),
self.local_url,
view_url(&self.token),
);
// TL;DR `--no-logging` is broken the same way here as it was in Go.
// Setting `--no-logging` gives a 400 response (invalid token) when you send a webhook to
// Play.
if self.logging {
printdoc!(
r#"
View logs and debug information at:
{}
To disable logging, run `{} listen --no-logging`
"#,
view_url(&self.token),
crate::BIN_NAME,
);
}
} else {
// Shows that a reconnection attempt succeeded after some failing initial attempts.
println!("Connected!");
Expand Down Expand Up @@ -222,17 +213,12 @@ impl Client {
pub async fn listen(
local_url: url::Url,
relay_token: String,
logging: bool,
relay_debug_url: Option<&str>,
relay_disable_security: bool,
) -> Result<()> {
let scheme = if relay_disable_security { "ws" } else { "wss" };
let api_host = relay_debug_url.unwrap_or(DEFAULT_API_HOST);
let token = if logging {
format!("c_{relay_token}")
} else {
relay_token
};
let token = format!("c_{relay_token}");

let websocket_url = format!("{scheme}://{api_host}/{API_PREFIX}/listen/").parse()?;

Expand All @@ -241,7 +227,6 @@ pub async fn listen(
websocket_url,
local_url,
http_client: HttpClient::new(),
logging,
};

const MAX_BACKOFF: Duration = Duration::from_millis(5000);
Expand All @@ -268,11 +253,7 @@ pub async fn listen(
eprintln!("Generating a new token for this session.");
client.token = {
let relay_token = generate_token()?;
if logging {
format!("c_{relay_token}")
} else {
relay_token
}
format!("c_{relay_token}")
};
}
} else {
Expand Down

0 comments on commit 9f1cceb

Please sign in to comment.