aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.rs
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2024-01-03 21:57:27 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2024-01-03 21:57:27 +0100
commitc2742cde3d034b2af9bbcee90765338ee094e6cc (patch)
treec35399d5d52725efbf3ebaaee83752574bf2ba1c /src/ui.rs
parent43201470d4092f54c176dd5ebd2d7b0bbf15192e (diff)
downloadcats-radio-node-c2742cde3d034b2af9bbcee90765338ee094e6cc.tar.gz
cats-radio-node-c2742cde3d034b2af9bbcee90765338ee094e6cc.tar.bz2
cats-radio-node-c2742cde3d034b2af9bbcee90765338ee094e6cc.zip
Add src/radio and freq config
Diffstat (limited to 'src/ui.rs')
-rw-r--r--src/ui.rs24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/ui.rs b/src/ui.rs
index aebcd4a..5a13bc0 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -21,27 +21,7 @@ pub async fn serve(port: u16, shared_state: SharedState) {
.route("/send", get(send))
.route("/settings", get(show_settings).post(post_settings))
.nest_service("/static", ServeDir::new("static"))
- /* requires tracing and tower, e.g.
- * tower = { version = "0.4", features = ["util", "timeout"] }
- * tower-http = { version = "0.5.0", features = ["add-extension", "trace"] }
- * tracing = "0.1"
- * tracing-subscriber = { version = "0.3", features = ["env-filter"] }
- .layer(
- ServiceBuilder::new()
- .layer(HandleErrorLayer::new(|error: BoxError| async move {
- ,if error.is::<tower::timeout::error::Elapsed>() {
- Ok(StatusCode::REQUEST_TIMEOUT)
- } else {
- Err((
- StatusCode::INTERNAL_SERVER_ERROR,
- format!("Unhandled internal error: {error}"),
- ))
- }
- }))
- .timeout(Duration::from_secs(10))
- .layer(TraceLayer::new_for_http())
- .into_inner(),
- )*/
+ /* For an example for timeouts and tracing, have a look at the git history */
.with_state(shared_state);
let listener = tokio::net::TcpListener::bind(("0.0.0.0", port)).await.unwrap();
@@ -122,6 +102,7 @@ async fn show_settings(State(state): State<SharedState>) -> SettingsTemplate<'st
#[derive(Deserialize, Debug)]
struct FormConfig {
+ freq: String,
callsign: String,
ssid: String,
icon: String,
@@ -164,6 +145,7 @@ impl TryFrom<FormConfig> for config::Config {
fn try_from(value: FormConfig) -> Result<Self, Self::Error> {
Ok(config::Config {
+ freq: value.freq.parse()?,
callsign: value.callsign,
ssid: value.ssid.parse()?,
icon: value.icon.parse()?,