Modulefastly 0.13.1

fastly::acl

Compute ACLs.

Management

Management of ACLs is done via api.fastly.com. See ACLs in Compute.

One or more ACLs can be linked to a Compute service. Once linked, an ACL can be accessed from within a Compute application via its linked name.

Usage

The following example opens an ACL by its linked name and then performs a lookup within the ACL of the client's IP. Different responses are returned depending on the result of the lookup (allow or block):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use fastly::{Error, Request, Response};
#[fastly::main]
fn main(req: Request) -> Result<Response, Error> {
let acl = fastly::Acl::open("my_acl").expect("can open acl");
let ip = req.get_client_ip_addr().expect("request has an ip");
let lookup = acl.try_lookup(ip)?;
match lookup {
Some(lookup_match) if lookup_match.is_allow() => {
// IP is allowed.
Ok(Response::from_body("allowed!"))
}
Some(_) => {
// IP is not allowed.
Ok(Response::from_status(403).with_body("blocked!"))
}
None => {
// No prefixes matched the IP.
Ok(Response::from_body("no match"))
}
}
}

Structs

AclA Compute ACL.
LookupMatchLookupMatch is the result of an ACL lookup which found a matching prefix.

Enums

LookupErrorErrors thrown on lookup failure.
MatchActionMatchAction represents an action associated with an ACL prefix.
OpenErrorErrors thrown when calling open.