1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Compute ACLs.
//!
//! # Management
//!
//! Management of ACLs is done via api.fastly.com.
//! See [ACLs in Compute](https://www.fastly.com/documentation/reference/api/acls/acls/).
//!
//! One or more ACLs can be
//! [linked](https://www.fastly.com/documentation/reference/api/services/resource/#create-resource) 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):
//!
//! ```no_run
//! 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"))
//! }
//! }
//! }
//! ```
use IpAddr;
pub use ;
pub use ;
/// A Compute ACL.