diff --git a/src/commands/publish/preview/mod.rs b/src/commands/publish/preview/mod.rs index 31c7394d8..ab566dd8b 100644 --- a/src/commands/publish/preview/mod.rs +++ b/src/commands/publish/preview/mod.rs @@ -14,6 +14,7 @@ use crate::settings::global_user::GlobalUser; use crate::settings::project::Project; use crate::terminal::message; +// Using this instead of just `https://cloudflareworkers.com` returns just the worker response to the CLI const PREVIEW_ADDRESS: &str = "https://00000000000000000000000000000000.cloudflareworkers.com"; #[derive(Debug, Deserialize)] @@ -42,7 +43,7 @@ struct V4ApiResponse { pub fn preview( project: &Project, user: Option, - method: Result, + method: HTTPMethod, body: Option, ) -> Result<(), failure::Error> { commands::build(&project)?; @@ -65,8 +66,6 @@ pub fn preview( script_id, session, https, preview_host ); - let method = method.unwrap_or_default(); - let worker_res = match method { HTTPMethod::Get => get(cookie, &client)?, HTTPMethod::Post => post(cookie, &client, body)?, diff --git a/src/main.rs b/src/main.rs index 90aaf91ad..b139f29a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -197,7 +197,7 @@ fn run() -> Result<(), failure::Error> { let project = settings::project::Project::new()?; let user = settings::global_user::GlobalUser::new().ok(); - let method = HTTPMethod::from_str(matches.value_of("method").unwrap_or("get")); + let method = HTTPMethod::from_str(matches.value_of("method").unwrap_or("get"))?; let body = match matches.value_of("body") { Some(s) => Some(s.to_string()),