Commit f35f1919 authored by Chunchi Che's avatar Chunchi Che

rerange code

parent d0edfe41
Pipeline #18036 failed with stages
in 3 minutes and 7 seconds
use std::{net::SocketAddr, str::FromStr};
use warp::Filter;
mod deck;
mod infra;
mod service;
const ADDR: &str = "127.0.0.1:3030";
......@@ -17,14 +17,11 @@ async fn main() -> anyhow::Result<()> {
.allow_header("content-type")
.allow_method("GET");
let deck = warp::path!("deck" / String).map(deck_service).with(cors);
let deck = warp::path!("deck" / String)
.map(service::deck_service)
.with(cors);
warp::serve(deck).run(SocketAddr::from_str(ADDR)?).await;
Ok(())
}
fn deck_service(param: String) -> String {
let deck = deck::Deck::from_path(format!("deck/{}", param)).unwrap_or_default();
serde_json::to_string(&deck).unwrap_or_default()
}
......@@ -53,3 +53,8 @@ impl Deck {
Ok(deck)
}
}
pub fn service(param: String) -> String {
let deck = Deck::from_path(format!("deck/{}", param)).unwrap_or_default();
serde_json::to_string(&deck).unwrap_or_default()
}
mod deck;
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