//! Route requests to backends based on URL path match
use fastly::{Error, Request, Response};
use regex::Regex;

#[fastly::main]
fn main(mut req: Request) -> Result<Response, Error> {
    // Route requests to backends based on URL path match
    // The backend of this example is https://httpbin.org/
    let re = Regex::new(r"^/some-(custom|dynamic|complex)-pattern/url/path$").unwrap();
    if re.is_match(req.get_url().path()) {
        req.set_path("/status/200");
    }
    Ok(req.send("origin_0")?)
}