Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include::_attributes.adoc[]
endif::[]
:imagesdir: ../assets/images

NOTE: To view an example policy project that uses DataWeave expressions, see https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/query/README.md[Query Policy Example^].
NOTE: To view an example policy project that uses DataWeave expressions, see https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/dataweave/README.md[DataWeave Policy Example^].

If the input DataWeave expression parameter is valid, the policy parses the expression and transforms it into a `pdk::script::Script` expression. To obtain the result of the script:

Expand Down Expand Up @@ -59,6 +59,11 @@ spec:

----

[NOTE]
====
Flex Gateway doesn't support DataWeave expressions with binary type results. To use the `dw::Binaries::fromBase64('dXNlcjpwYXNz')` function, transform the result to a string. Transform the binary output to a string with the `dw::util::Coercions::toString(binary: Binary, encoding: String): String` function. For example, `#[dw::util::Coercions::toString(dw::core::Binaries::fromBase64('dXNlcjpwYXNz'), 'UTF-8')]`. If using a different function that transforms the binary by default, such as `#[splitBy(dw::core::Binaries::fromBase64('dXNlcjpwYXNz'), ':')]`, you can skip manually transforming the binary.
====

Use the following Rust snippet:

[source,rust]
Expand Down Expand Up @@ -131,6 +136,7 @@ After one of the binding methods is called, you can confirm the expression was c
evaluator.is_ready()
----


== See Also

* xref:policies-pdk-configure-features.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ The `dataweave` variable supports the following expression bindings:
vars: []
----

* `payload`: The body of the incoming request. Define the `mimeType` as either `text` or `json` to set how to read the payload. By default, `mimeType` is set to `text`. To restrict the use of the `payload` variable, you must exclude the payload variable, for example:
* `payload`: The body of the incoming request. Define the `mimeType` as either `text`, `json`, or `xml` to set how to read the payload. By default, `mimeType` is set to `text`. If the `content-type` header is bound to the evaluator, then the payload is interpreted according to the value of the `content-type` header. To restrict the use of the `payload` variable, exclude the payload variable as shown in this example:
+
[source,yaml]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ PDK includes the following API example policies:
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/cors-validation/README.md[CORS Validation Policy Example]: Use the CORS Validation Policy as an example of how to use functions of the xref:policies-pdk-configure-features-cors.adoc[CORS Library] in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/crypto/README.md[Crypto Policy Example]: Use the Crypto Policy as an example of how to use xref:policies-pdk-configure-features-libraries.adoc[third-party libraries] that provide cryptography capabilities in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/data-caching/README.md[Data Caching Policy Example]: Use the Data Caching Policy as an example of how to implement xref:policies-pdk-configure-features-caching.adoc[data caching] in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/dataweave/README.md[DataWeave Policy Example]: Use the DataWeave Policy as an example of how to handle xref:policies-pdk-configure-features-dataweave.adoc[custom DataWeave expressions] in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/jwt-validation/README.md[JWT Validation Policy Example]: Use the JWT Validation Policy as an example of how to use functions of the xref:policies-pdk-configure-features-jwt.adoc[JWT Library] in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/metrics/README.md[Metrics Policy Example]: Use the Metrics Policy as an example of how to periodically send data to a metric ingestion service by implementing xref:policies-pdk-configure-features-timer.adoc[periodic functions] and xref:policies-pdk-configure-features-http-request.adoc[HTTP calls].
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/query/README.md[Query Policy Example]: Use the Query Policy as an example of how to handle xref:policies-pdk-configure-features-dataweave.adoc[DataWeave expressions] in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/query/README.md[Query Policy Example]: Use the Query Policy as an example of how to handle query parameters in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/simple-oauth-2-validation/README.md[Simple OAuth 2.0 Validation Policy Example]: Use the Simple OAuth 2.0 Validation Policy as an example of how to implement xref:policies-pdk-configure-features-http-request.adoc[HTTP calls] in your custom policy.
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/spike/README.md[Spike Policy Example]: Use the Spike Policy as an example of how to configure worker spike control by implementing xref:policies-pdk-configure-features-timer.adoc[periodic functions].
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/stream-payload/README.md[Stream Payload Policy Example]: Use the Stream Payload Policy as an example of how to xref:policies-pdk-configure-features-headers.adoc#streaming-bodies[read payload bodies larger than 1MB].
* https://github.com/mulesoft/pdk-custom-policy-examples/blob/{template-policies-url-ver-var}/tls-calls/README.md[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.

== A2A and MCP Server Policy Examples
Expand Down