Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Max KvR committed Feb 16, 2024
1 parent 77d21db commit fe749d3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions examples/webhook-axum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//! ```
use axum::{
async_trait,
body::Body,
extract::FromRequest,
http::{Request, StatusCode},
response::{IntoResponse, Response},
async_trait,
routing::post,
body::Body,
Error, Router,
};
use stripe::{Event, EventObject, EventType};
Expand All @@ -30,23 +30,20 @@ async fn main() {
// build our application with a route
let app = Router::new().route("/stripe_webhooks", post(handle_webhook));

let listener = tokio::net::TcpListener::bind("127.0.0.1:4242")
.await
.unwrap();

let listener = tokio::net::TcpListener::bind("127.0.0.1:4242").await.unwrap();

println!("listening on {}", listener.local_addr().unwrap());

axum::serve(listener, app).await.unwrap();
}

struct StripeEvent(Event);


#[async_trait]
impl<S> FromRequest<S> for StripeEvent
where
String: FromRequest<S>,
S: Send + Sync,
where
String: FromRequest<S>,
S: Send + Sync,
{
type Rejection = Response;

Expand Down Expand Up @@ -83,4 +80,3 @@ async fn handle_webhook(StripeEvent(event): StripeEvent) {
_ => println!("Unknown event encountered in webhook: {:?}", event.type_),
}
}

0 comments on commit fe749d3

Please sign in to comment.