- main
- manifest
- deps
- main
- Install
- Run
use fastly::{Error, Request, Response};
const BACKEND_PRODUCTION: &str = "origin_0";
const BACKEND_TEST: &str = "origin_1";
#[fastly::main]
fn main(mut req_production: Request) -> Result<Response, Error> {
log_fastly::init_simple("my_log", log::LevelFilter::Info);
fastly::log::set_panic_endpoint("my_log").unwrap();
let req_test = req_production.clone_with_body();
let pending_req_production = req_production.send_async(BACKEND_PRODUCTION)?;
let pending_req_test = req_test.send_async(BACKEND_TEST)?;
let resp_production = pending_req_production.wait()?;
let resp_test = pending_req_test.wait()?;
let is_same_status = resp_production.get_status() == resp_test.get_status();
let is_same_content_len =
resp_production.get_content_length() == resp_test.get_content_length();
if is_same_status && is_same_content_len {
log::info!("Prod and test are the same");
} else {
log::info!("The production and test environments returned different content");
}
Ok(resp_production)
}