rename api context

This commit is contained in:
Champlin, Saji 2024-07-31 13:31:35 -05:00
parent 37f67323e1
commit 2c34886dc5
2 changed files with 5 additions and 5 deletions

View file

@ -22,12 +22,12 @@ pub enum ApiError {
}
#[derive(Clone)]
pub struct Context {
pub struct AppState {
display_channel: Sender<DisplaySetCommand>,
display_task: Arc<JoinHandle<()>>,
}
impl Context {
impl AppState {
#[must_use]
pub fn new(disp: Box<dyn EInkPanel + Send>) -> Self {
let (tx, rx) = mpsc::channel(2);
@ -86,7 +86,7 @@ pub async fn display_task(
/// API routes for axum
/// Start with the basics: Send an image, crop it, dither, and upload.
/// we defer the upload to a separate task.
pub fn router() -> Router<Context> {
pub fn router() -> Router<AppState> {
Router::new()
.route("/setimage", post(set_image))
.route("/preview", post(preview_image))
@ -149,7 +149,7 @@ where
#[instrument(skip(ctx))]
async fn set_image(
State(ctx): State<Context>,
State(ctx): State<AppState>,
img_req: ImageRequest,
) -> Result<impl IntoResponse, AppError> {
// FIXME: resize image to 800x480 to match the eink panel.

View file

@ -80,7 +80,7 @@ async fn main() -> anyhow::Result<()> {
Command::Serve => {
let display = FakeEInk {};
let ctx = api::Context::new(Box::new(display));
let ctx = api::AppState::new(Box::new(display));
let app = api::router().with_state(ctx);
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;