- main
- manifest
- deps
- main
- Install
- Run
use fastly::http::StatusCode;
use fastly::{Error, Request, Response};
const BACKEND_ORIGIN_0: &str = "origin_0";
const BACKEND_ORIGIN_1: &str = "origin_1";
#[fastly::main]
fn main(req: Request) -> Result<Response, Error> {
match (req.get_path(), req.get_query_str()) {
("/", None) => Ok(req.send(BACKEND_ORIGIN_0)?),
(s, _) if s == "/status" || s.starts_with("/status/") => Ok(req.send(BACKEND_ORIGIN_1)?),
_ => Ok(
Response::from_body("The page you requested could not be found")
.with_status(StatusCode::NOT_FOUND),
),
}
}