Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
refactor: pass method instead of result
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleymichal committed Aug 13, 2019
1 parent 0ade33f commit 60be134
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/commands/publish/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -42,7 +43,7 @@ struct V4ApiResponse {
pub fn preview(
project: &Project,
user: Option<GlobalUser>,
method: Result<HTTPMethod, failure::Error>,
method: HTTPMethod,
body: Option<String>,
) -> Result<(), failure::Error> {
commands::build(&project)?;
Expand All @@ -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)?,
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 60be134

Please sign in to comment.