---
schema_version: "1"
id: c69fd5f519fb0d924e9ca381b56b9234d6f9c729b60a486efad9f1cc91874202
title: Injecting Parameters
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/pdk/1.6/policies-pdk-configure-features-inject-parameters.md
canonical_url: https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-inject-parameters
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 816c39ea63492f6f27a3fdd085ec32718e64d5f6e5d9575038f16fbbac08139b
description: MuleSoft Documentation Site
release: "1.6"
latest: false
---
---
product: Omni Gateway Policy Development Kit (PDK)
version: 1.6
---

# Injecting Parameters

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Flex Gateway Policy Development Kit (PDK) provides the following parameters that you can inject into
the `#[entrypoint]` configuration function:

- `Configuration`: Provides the policy’s configuration parameters. For information about how to
  define configuration parameters, see
  [Defining a Policy Schema Definition](https://docs.mulesoft.com/pdk/1.6/policies-pdk-create-schema-definition).

- `Metadata`: Provides metadata about the policy, the Flex Gateway instance, the API instance, and
  the Anypoint Organization. For more information about the metadata provided, see
  [Accessing Policy Metadata](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-metadata).

- `HttpClient`: Enables the policy to make HTTP calls. For more information about how to make HTTP
  calls from the policy, see
  [Performing an HTTP Call](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-http-request).

- `CacheBuilder`: Provides the caching features of the policy. For more information about caching,
  see
  [Sharing Data Between Workers and Configuring Caching](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-caching).

- `StreamProperties`: Provides a structure to share properties with other policies that process the
  same request. For more information about sharing information between policies, see
  [Sharing Data Between Policies](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-streamproperties).

- `` PolicyViolations` ``: Provides a mechanism to report policy violations for your monitoring
  dashboards. For more information about policy violations, see
  [Reporting Policy Violations](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-violations).

- `RateLimitBuilder`: Provides rate limiting functionality to control request rates. For more
  information about rate limiting, see
  [Rate Limiting Requests](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-rate-limiting).

You can also directly inject the `HttpClient` and `StreamProperties` parameter into the `on_request`
or `on_response` wrapped functions. For example, if you need to perform an HTTP call inside the
`on_request` function, inject `HTTPClient` directly into that function.

For best practice, inject the parameters only where they must be used. However, if the parameters
require initialization steps that need to be executed only one time when the policy is applied, it
is best to inject the parameters into the `#[entrypoint]` to complete the configuration steps to
increase the performance of the wrapped functions.

## Inject Parameters into the on\_request and on\_response Wrapped Functions

The wrapped functions accept the following parameters:

- `HttpClient`: Enables the policy to make HTTP calls. For more information about how to make HTTP
  calls from the policy, see
  [Performing an HTTP Call](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-http-request).

- `StreamProperties`: Provides a structure to share properties with other policies that process the
  same request. For more information about sharing information between policies, see
  [Sharing Data Between Policies](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-streamproperties).

- `RequestState`: Provides access to the different stages of request filtering to operate over the
  incoming requests headers and body. `RequestState` is only available in `on_request` functions. To
  read and write to the headers and body in the\`RequestState\`, see
  [Reading and Writing Request Headers and Bodies](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-headers).

- `ResponseState`: Provides access to the different stages of request filtering to operate over the
  upstream responses headers and body. `ResponseState` is only available in `on_response` functions.
  To read and write to the headers and body in the `ResponseState`, see
  [Reading and Writing Request Headers and Bodies](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-headers).

- `RequestData`: Share data between the `on_request` and\`on\_response\` functions. `RequestData` is
  only available in `on_response` functions. To learn more about `RequestData`, see
  [Sharing Data Between Requests and Responses](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-share-data).

- `Authentication`: Provides access to read authentication data or share it with other policies. To
  learn more about `Authentication`, see
  [Accessing Request Authentication Information](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features-authentication).

If your wrapped functions only receive these parameters, the lambda is not required in the wrapper.
For example, if the signature of the function is:

```Rust
async fn request_filter(state: RequestState) -> RequestData<String>;
async fn response_filter(state: ResponseState, path: RequestData<String>);
```

The following example demonstrates defining the lambda of a function definition:

```Rust
let filter = on_request(|request_state| request_filter(request_state))
    .on_response(|response_state, request_data| response_filter(response_state, request_data));
```

Instead of defining the lambda, you can use the following function definition:

```Rust
let filter = on_request(request_filter)
        .on_response(response_filter);
```

If your wrapped functions require other parameters, such as the configuration parameters defined in
the `#[entrypoint]` function, inject the parameters into the wrapped functions. To pass the
parameters, define the lambda and send a variable reference, for example:

```Rust
async fn request_filter(state: RequestState, conf: &Config, tuple: &(u32, u32)) {
...
}

#[entrypoint]
async fn configure(launcher: Launcher, Configuration(bytes): Configuration) -> Result<()> {
    let config = serde_json::from_slice(&bytes)?;
    let tuple: (u32, u32) = (10, 10);

    let filter = on_request(|request_state| request_filter(request_state, &config, &tuple));

    launcher
        .launch(filter)
        .await?;

    Ok(())
}
```

## See Also

- [Implementing Your Custom Policy Features in Rust](https://docs.mulesoft.com/pdk/1.6/policies-pdk-configure-features)
