Using Regex in Mapping Rules

Posted on

Based on the documentation provided here: https://access.redhat.com/documentation/en-us/red_hat_3scale/2.1/html-single/deployment_options/index#apicast-self-managed-nginx-config-files

I see it is possible to add a wildcard to a mapping rule. Is is possible to use a specific regex in a mapping rule as well? See the example below for our use case/need for this functionality:

We have two API endpoints:

GET /members/agreements - Get specific agreement data for all members

GET /members/12345 - Get high level member information for a specific member (12345 represents a memberID that will be different across members)

We are wanting to create mapping rules to identify hits to both of these API's separately. Given the random nature of a memberID, we thought to use the wildcard syntax to track hits for that API. So we have two mapping rules like this:

/members/agreements
/members/{memberID}

Since a wild card matches everything, a request to GET /members/agreements will register as a hit for both GET /members/agreements and GET /members/{memberID}, which is problematic. So we are in need of a more specific way of identifying certain APIs that use ID's in the URI instead of a catch all wild card. Since using ID's in the URI is pretty standard RESTful practice, I have to think there is a way we can achieve this.

Responses