Initial setup
This commit is contained in:
7 files changed
+1863
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
use axum::{Router, extract::Path, http::{HeaderMap, header::ACCEPT}, response::{Html, IntoResponse}, routing::get, serve};
|
||||
use tokio::net::TcpListener;
|
||||
mod db;
|
||||
mod paste;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let app = Router::new()
|
||||
.route("/", get(|| async {}))
|
||||
.route("/{id}", get(get_note));
|
||||
|
||||
let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
println!("Listening on http://localhost:3000");
|
||||
serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
||||
async fn get_note(Path(id): Path<String>, headers: HeaderMap) -> impl IntoResponse {
|
||||
let return_html = headers.get(ACCEPT)
|
||||
.and_then(|v|v.to_str().ok())
|
||||
.and_then(|h| Some(h.contains("text/html")))
|
||||
.unwrap_or_default();
|
||||
|
||||
Html::from("test")
|
||||
}
|
||||
Reference in new issue
Block a user