git clone https://github.com/mulesoft/pdk-custom-policy-examples.git
Custom Policy Examples
Flex Gateway Policy Development Kit (PDK) provides example policy projects to get started configuring your Rust source code.
Find all policy examples and their documentation in the PDK Custom Policy GitHub Repository.
PDK offers the following example policies:
-
Block Policy Example: Use the Block Policy as an example of how to block IP ranges by implementing periodic functions and HTTP calls.
-
Certification Policy Example: Use the Certification Policy as an example of how to obtain data concerning connection certificates.
-
CORS Validation Policy Example: Use the CORS Validation Policy as an example of how to use functions of the CORS Library in your custom policy.
-
Crypto Policy Example: Use the Crypto Policy as an example of how to use third-party libraries that provide cryptography capabilities in your custom policy.
-
Data Caching Policy Example: Use the Data Caching Policy as an example of how to implement data caching in your custom policy.
-
JWT Validation Policy Example: Use the JWT Validation Policy as an example of how to use functions of the JWT Library in your custom policy.
-
Metrics Policy Example: Use the Metrics Policy as an example of how to periodically send data to a metric ingestion service by implementing periodic functions and HTTP calls.
-
Query Policy Example: Use the Query Policy as an example of how to handle DataWeave expressions in your custom policy.
-
Simple OAuth 2.0 Validation Policy Example: Use the Simple OAuth 2.0 Validation Policy as an example of how to implement HTTP calls in your custom policy.
-
Spike Policy Example: Use the Spike Policy as an example of how to configure worker spike control by implementing periodic functions.
-
TLS Calls Policy Example: Use the TLS Calls Policy as an example of how to make HTTPS calls in your policy without installing certificates on the operating system running Flex Gateway.
Set Up an Example Policy Project
To begin using an example policy project:
-
Ensure you have installed all the PDK prerequisites.
-
Clone the PDK Custom Policy GitHub Repository with the following command or your preferred GitHub interface:
-
Navigate to the newly cloned directory, then copy and paste the directory of your desired policy into a new location.
-
In the
cargo.toml
file of the copied policy example, replace thegroup-id
with your group ID, for example:group_id = "<your-group-id>"
-
Run the
make setup
command.make setup
-
Navigate to the
README.md
file in the example policy to read more about the policy and how to test it.