Commit 79431d64 authored by Chunchi Che's avatar Chunchi Che

add todo cards service

parent f35f1919
Pipeline #18037 failed with stages
in 5 minutes and 49 seconds
...@@ -4,13 +4,15 @@ use warp::Filter; ...@@ -4,13 +4,15 @@ use warp::Filter;
mod infra; mod infra;
mod service; mod service;
const ADDR: &str = "127.0.0.1:3030"; // TODO: Configurable
const DECK_ADDR: &str = "127.0.0.1:3030";
const CARDS_ADDR: &str = "127.0.0.1:3033";
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
pretty_env_logger::try_init()?; pretty_env_logger::try_init()?;
// todo: use CORS correctly // TODO: use CORS correctly
let cors = warp::cors() let cors = warp::cors()
.allow_any_origin() .allow_any_origin()
.allow_credentials(true) .allow_credentials(true)
...@@ -19,9 +21,18 @@ async fn main() -> anyhow::Result<()> { ...@@ -19,9 +21,18 @@ async fn main() -> anyhow::Result<()> {
let deck = warp::path!("deck" / String) let deck = warp::path!("deck" / String)
.map(service::deck_service) .map(service::deck_service)
.with(cors); .with(cors.clone());
warp::serve(deck)
.run(SocketAddr::from_str(DECK_ADDR)?)
.await;
warp::serve(deck).run(SocketAddr::from_str(ADDR)?).await; // TODO: cards服务暂时仅支持单卡查询
let cards = warp::path!("cards" / String)
.map(service::cards_service)
.with(cors);
warp::serve(cards)
.run(SocketAddr::from_str(CARDS_ADDR)?)
.await;
Ok(()) Ok(())
} }
pub fn service(param: String) -> String {
todo!()
}
mod cards;
mod deck; mod deck;
pub use cards::service as cards_service;
pub use deck::service as deck_service; pub use deck::service as deck_service;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment