feat(api): wire POST /tabs/parse endpoint with fetcher and parser

This commit is contained in:
2026-04-08 01:56:06 +02:00
parent fe7d2dbceb
commit 0444d11fb4
4 changed files with 93 additions and 0 deletions

24
crates/api/src/main.rs Normal file
View 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();
}