Skip to content

Commit

Permalink
Extract ApiPath struct
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Sep 30, 2024
1 parent f12f155 commit b01873f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use axum::Router;
use futures::future::{BoxFuture, Future, FutureExt};
use net_literals::addr;
use sailfish::TemplateOnce;
use serde::Deserialize;
use std::collections::BTreeMap;
use std::net::SocketAddr;
use std::sync::Arc;
Expand Down Expand Up @@ -144,6 +145,13 @@ impl BoundServer {
}
}

#[derive(Deserialize)]
struct ApiPath {
device_type: DevicePath,
device_number: usize,
action: String,
}

impl Server {
/// Binds the Alpaca and discovery servers to local ports.
pub async fn bind(self) -> eyre::Result<BoundServer> {
Expand Down Expand Up @@ -286,11 +294,11 @@ impl Server {
.route(
"/api/v1/:device_type/:device_number/:action",
axum::routing::any(
move |Path((DevicePath(device_type), device_number, action)): Path<(
DevicePath,
usize,
String,
)>,
move |Path(ApiPath {
device_type: DevicePath(device_type),
device_number,
action,
}),
#[cfg(feature = "camera")] headers: http::HeaderMap,
server_handler: ServerHandler| async move {
#[cfg(feature = "camera")]
Expand Down

0 comments on commit b01873f

Please sign in to comment.