Skip to content

Commit

Permalink
ICS forces calendar output
Browse files Browse the repository at this point in the history
  • Loading branch information
stabbylambda committed Feb 21, 2024
1 parent ee119e4 commit 7d4bb54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lambda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ pub mod trashcal;

#[instrument]
pub async fn get_trashcal(id: &str, accept: &str) -> Result<Response<Body>> {
let is_ics_request = id.contains(".ics");

let calendar = trashcal(id).await?;

// build the response as either json or calendar
let resp = Response::builder().status(StatusCode::OK);
let resp = if accept.starts_with("application/json") {
let resp = if accept.starts_with("application/json") && !is_ics_request {
info!(message = "Returning calendar as JSON");
let json = serde_json::to_string_pretty(&calendar)?;

Expand Down
4 changes: 3 additions & 1 deletion lambda/tests/data/path_based_with_extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"rawPath": "/a4Ot0000001E8i4EAC.ics",
"rawQueryString": "",
"cookies": [],
"headers": {},
"headers": {
"accept": "application/json, text/plain, */*"
},
"queryStringParameters": {},
"requestContext": {
"accountId": "123456789012",
Expand Down

0 comments on commit 7d4bb54

Please sign in to comment.