Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Jan 17, 2021
1 parent 71fab89 commit 2f391df
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions warp/token-from-header/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,20 @@ async fn main() {
))
});

let routes = graphql_subscription_with_data(
schema,
|value| async {
#[derive(serde_derive::Deserialize)]
struct Payload {
token: String,
}
let routes = graphql_subscription_with_data(schema, |value| async {
#[derive(serde_derive::Deserialize)]
struct Payload {
token: String,
}

if let Ok(payload) = serde_json::from_value::<Payload>(value) {
let mut data = Data::default();
data.insert(MyToken(payload.token));
Ok(data)
} else {
Err("Token is required".into())
}
},
)
if let Ok(payload) = serde_json::from_value::<Payload>(value) {
let mut data = Data::default();
data.insert(MyToken(payload.token));
Ok(data)
} else {
Err("Token is required".into())
}
})
.or(graphql_playground)
.or(graphql_post);
warp::serve(routes).run(([0, 0, 0, 0], 8000)).await;
Expand Down

0 comments on commit 2f391df

Please sign in to comment.