add / route
This commit is contained in:
parent
164811388f
commit
71825744da
|
@ -38,6 +38,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
});
|
||||
|
||||
let router = Router::default()
|
||||
.route("/", get(routes::root))
|
||||
.route("/i/:id", get(routes::i))
|
||||
.route("/i/:id", delete(routes::delete))
|
||||
.route("/api/upload", post(routes::upload))
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
mod delete;
|
||||
mod i;
|
||||
mod new_key;
|
||||
mod root;
|
||||
mod upload;
|
||||
|
||||
pub use delete::delete;
|
||||
pub use i::get as i;
|
||||
pub use new_key::post as new_key;
|
||||
pub use root::get as root;
|
||||
pub use upload::post as upload;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
use crate::state::ReqState;
|
||||
use axum::{extract::State, response::IntoResponse};
|
||||
use hyper::StatusCode;
|
||||
|
||||
pub async fn get(State(state): ReqState) -> impl IntoResponse {
|
||||
let file_count = state.files_dir.read_dir();
|
||||
|
||||
if file_count.is_err() {
|
||||
return Err(StatusCode::INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
let file_count = file_count.unwrap().count();
|
||||
Ok("u".repeat(file_count).into_response())
|
||||
}
|
Loading…
Reference in New Issue