diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers/mod.rs | 1 | ||||
-rw-r--r-- | src/handlers/ships.rs | 23 | ||||
-rw-r--r-- | src/main.rs | 7 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs new file mode 100644 index 0000000..2b5bfaf --- /dev/null +++ b/src/handlers/mod.rs @@ -0,0 +1 @@ +pub mod ships; diff --git a/src/handlers/ships.rs b/src/handlers/ships.rs new file mode 100644 index 0000000..5e8c000 --- /dev/null +++ b/src/handlers/ships.rs @@ -0,0 +1,23 @@ +use axum::{Json, extract::Path}; +use solarlib::ship::{Ship, Sha256}; + +use crate::errors::{JsonResult, StringResult}; + + +pub async fn list() -> JsonResult<Json<Vec<Ship>>> { + let mut result: Vec<Ship> = Vec::new(); + + Ok(Json(result)) +} + +pub async fn new(Json(new_ship): Json<Ship>) -> StringResult { + unimplemented!(); +} + +pub async fn update(Json(new_ship): Json<Ship>) -> StringResult { + todo!(); +} + +pub async fn delete(Path(shasum): Path<Sha256>) -> StringResult { + todo!(); +} diff --git a/src/main.rs b/src/main.rs index ba319d9..31271e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use axum::{ error_handling::HandleErrorLayer, http::StatusCode, response::IntoResponse, - routing::get, + routing::{get, post, delete}, Json, Router }; @@ -32,7 +32,10 @@ async fn main() { let app = Router::new() .route("/health", get(health_check)) - .route("/waifus/list", get(handlers::waifus::list)) + .route("/ships/list", get(handlers::ships::list)) + .route("/ships/new", post(handlers::ships::new)) + .route("/ships/update", post(handlers::ships::update)) + .route("/ships/delete/:shasum", delete(handlers::ships::delete)) .layer( ServiceBuilder::new() .layer(HandleErrorLayer::new(|error: BoxError| async move { if error.is::<tower::timeout::error::Elapsed>() { |