-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5d4fa5
commit 190256f
Showing
4 changed files
with
46 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use axum::Router; | ||
use cdk::mint::Mint; | ||
use tokio::sync::Notify; | ||
use tower_http::cors::CorsLayer; | ||
|
||
pub async fn start_mint(addr: &str, port: u16, mint: Mint) -> Result<()> { | ||
let mint_arc = Arc::new(mint); | ||
|
||
let v1_service = cdk_axum::create_mint_router(Arc::clone(&mint_arc)) | ||
.await | ||
.unwrap(); | ||
|
||
let mint_service = Router::new() | ||
.merge(v1_service) | ||
.layer(CorsLayer::permissive()); | ||
|
||
let mint = Arc::clone(&mint_arc); | ||
|
||
let shutdown = Arc::new(Notify::new()); | ||
|
||
tokio::spawn({ | ||
let shutdown = Arc::clone(&shutdown); | ||
async move { mint.wait_for_paid_invoices(shutdown).await } | ||
}); | ||
|
||
println!("Staring Axum server"); | ||
axum::Server::bind(&format!("{}:{}", addr, port).as_str().parse().unwrap()) | ||
.serve(mint_service.into_make_service()) | ||
.await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters