At first glance, if you use the Variable Type as "Request Context Variables", you might be able to implement this.

Request Context Variables

Resource Indicates the requested resource, such as /directory_name/.

A request context variable can capture any of this information and can make it available for inclusion in a policy expression or response. The key benefit of this type of variable is to provide fine-grained request context information without any programming logic.