Skip to content

Commit

Permalink
Keep pass in memory
Browse files Browse the repository at this point in the history
  • Loading branch information
praseodym committed Oct 11, 2023
1 parent 0350f0c commit a86f6de
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/passes.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::io::Cursor;
use std::{env, path::Path};

use axum::{extract::Query, http::header, response::IntoResponse};
Expand Down Expand Up @@ -78,17 +79,16 @@ pub async fn passes_handler(Query(data): Query<PassModel>) -> Result<impl IntoRe
"-- Loading certificate from {}",
env::var("CERTIFICATE_PATH").unwrap()
);
// Sign, comprass and save pass
pass.export_to_file(
env::var("CERTIFICATE_PATH").unwrap().as_str(),
env::var("CERTIFICATE_PASSWORD").unwrap().as_str(),
Path::new("keys/apple_wdrca.pem"),
Path::new("./Eventpass.pkpass"),
)
.unwrap();

// Get content of file as generic bytes
let pass_content = std::fs::read("./Eventpass.pkpass").unwrap();

// Sign, compress and save pass
let pass_cursor = pass
.export(
env::var("CERTIFICATE_PATH").unwrap().as_str(),
env::var("CERTIFICATE_PASSWORD").unwrap().as_str(),
Path::new("keys/apple_wdrca.pem"),
Cursor::new(Vec::<u8>::new()),
)
.unwrap();

// Return content of file as response
Ok((
Expand All @@ -99,6 +99,6 @@ pub async fn passes_handler(Query(data): Query<PassModel>) -> Result<impl IntoRe
"attachment; filename=\"Eventpass.pkpass\"",
),
],
pass_content,
pass_cursor.into_inner(),
))
}

0 comments on commit a86f6de

Please sign in to comment.