rust router skeleton code
Just a basic axum setup with modules
This commit is contained in:
parent
1f6544a75e
commit
1d577ef396
4 changed files with 653 additions and 0 deletions
22
rust/src/router.rs
Normal file
22
rust/src/router.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use axum::{
|
||||
routing::get,
|
||||
extract::Path,
|
||||
Router,
|
||||
};
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
pub async fn setup() {
|
||||
let app = Router::new()
|
||||
.route("/xrpc/{nsid}", get(xrpc_get).post(xrpc_post));
|
||||
|
||||
let listener = TcpListener::bind("0.0.0.0:6702").await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn xrpc_get(Path(nsid): Path<String>) -> String {
|
||||
nsid
|
||||
}
|
||||
|
||||
async fn xrpc_post(Path(nsid): Path<String>) -> String {
|
||||
nsid
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue