diff options
author | alyx <alyx@aleteoryx.me> | 2023-08-10 20:45:01 -0400 |
---|---|---|
committer | alyx <alyx@aleteoryx.me> | 2023-08-10 20:45:01 -0400 |
commit | 9edafd94b00a73662d51824dbcba0a018e2140cf (patch) | |
tree | 3389bb7be8296ccfa1b287cb23ba4b45f35f1b2e /src/ctx.rs | |
parent | 0216a2a99ff28b1f5f102f52b7d980bbc4afc729 (diff) | |
download | lfm_embed-9edafd94b00a73662d51824dbcba0a018e2140cf.tar.gz lfm_embed-9edafd94b00a73662d51824dbcba0a018e2140cf.tar.bz2 lfm_embed-9edafd94b00a73662d51824dbcba0a018e2140cf.zip |
Create plain theme, do some escaping, fix some busted envvars, document themes.
Diffstat (limited to 'src/ctx.rs')
-rw-r--r-- | src/ctx.rs | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1,9 +1,11 @@ use reqwest::StatusCode; use super::deserialize as de; use std::sync::Arc; +use std::collections::BTreeMap; pub mod model { use std::sync::Arc; + use std::collections::BTreeMap; /// The theme representation of a user. #[derive(serde::Serialize, Debug)] @@ -73,14 +75,15 @@ pub mod model { /// Contains text explaining a potential error. Error { error: &'static str }, /// Contains data about a user and what they're listening to. - Data { user: User, scrobble: Scrobble } + Data { user: User, scrobble: Scrobble, query: BTreeMap<String, String> } } } #[derive(Debug)] pub struct ResponseCtx(pub model::Data, pub StatusCode); -impl From<Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>> for ResponseCtx { - fn from(v: Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>) -> ResponseCtx { +impl From<(Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>, BTreeMap<String, String>)> for ResponseCtx { + fn from(v: (Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>, BTreeMap<String, String>)) -> ResponseCtx { + let (v, q) = v; match v { Ok(a) => { let (user, track) = a.as_ref(); @@ -111,7 +114,8 @@ impl From<Result<Arc<(de::User, de::Track)>, (StatusCode, &'static str)>> for Re now_playing: track.attr.nowplaying, url: track.url.clone(), loved: track.loved.unwrap_or(false) - } + }, + query: q }, StatusCode::OK) }, Err((status, error)) => { |