feat(api): wire POST /tabs/parse endpoint with fetcher and parser
This commit is contained in:
24
crates/api/src/main.rs
Normal file
24
crates/api/src/main.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
mod routes;
|
||||
|
||||
use axum::{routing::post, Router};
|
||||
use routes::tabs::{parse_tab, AppState};
|
||||
use std::sync::Arc;
|
||||
use ug_parser::{UgHtmlParser, UgTabFetcher};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let state = Arc::new(AppState {
|
||||
fetcher: Box::new(UgTabFetcher::new()),
|
||||
parser: Box::new(UgHtmlParser),
|
||||
});
|
||||
|
||||
let app = Router::new()
|
||||
.route("/tabs/parse", post(parse_tab))
|
||||
.with_state(state);
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
tracing::info!("listening on {}", listener.local_addr().unwrap());
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user