wip: api router
This commit is contained in:
parent
b5073bec89
commit
a00e0dd08d
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -1358,6 +1358,7 @@ dependencies = [
|
||||||
"palette",
|
"palette",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rgb",
|
"rgb",
|
||||||
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1852,18 +1853,18 @@ checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.62"
|
version = "1.0.63"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb"
|
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.62"
|
version = "1.0.63"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c"
|
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
@ -20,4 +20,5 @@ num-traits = "0.2.19"
|
||||||
palette = "0.7.6"
|
palette = "0.7.6"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
rgb = "0.8.40"
|
rgb = "0.8.40"
|
||||||
|
thiserror = "1.0.63"
|
||||||
tokio = { version = "1.38.1", features = ["full"] }
|
tokio = { version = "1.38.1", features = ["full"] }
|
||||||
|
|
16
src/api.rs
16
src/api.rs
|
@ -1,7 +1,21 @@
|
||||||
use axum::{Router};
|
use axum::{extract::State, http::StatusCode, routing::post, Router};
|
||||||
|
|
||||||
|
use crate::display::Wrapper;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct ApiContext {
|
||||||
|
display: Arc<Mutex<Wrapper>>,
|
||||||
|
}
|
||||||
/// API routes for axum
|
/// API routes for axum
|
||||||
/// Start with the basics: Send an image, crop it, dither, and upload.
|
/// Start with the basics: Send an image, crop it, dither, and upload.
|
||||||
/// we defer the upload to a separate task.
|
/// we defer the upload to a separate task.
|
||||||
|
pub fn router() -> Router<ApiContext> {
|
||||||
|
Router::new()
|
||||||
|
.route("/setimage", post(set_image))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn set_image(State(ctx): State<ApiContext>) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
1
src/errors.rs
Normal file
1
src/errors.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
use thiserror;
|
|
@ -2,6 +2,7 @@
|
||||||
pub mod display;
|
pub mod display;
|
||||||
pub mod imageproc;
|
pub mod imageproc;
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod errors;
|
||||||
|
|
||||||
use crate::display::Wrapper;
|
use crate::display::Wrapper;
|
||||||
use crate::imageproc::{DiffusionMatrix, Ditherer, EInkImage, ErrorDiffusionDither};
|
use crate::imageproc::{DiffusionMatrix, Ditherer, EInkImage, ErrorDiffusionDither};
|
||||||
|
@ -48,5 +49,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
display.test()?;
|
display.test()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches!(cli.command, Command::Serve) {
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue