-
Notifications
You must be signed in to change notification settings - Fork 8
Matching Expression Language
In Carapace configuration, properties like route and filter features a field match for defining whether to apply what defined. The way you can define whether to apply a route or a filter is by an integrated expression language built just to define matching conditions about incoming request properties like uri, headers, method etc. In this section will be exposed the Matching Expression Language to be used within matchers, a bounch of request properties that can be managed with it toghether with some examples.
The expression language just allows boolean expression by composing comparing conditions between constant values and the Request properties.
Each property has to be specified as
request.PROPERTY_NAME
Right now, available operators are:
- Equals operator = "VALUE"
- Regular Expression operator ~ "VALUE"
- Boolean operator and
- Boolean operator or
- Boolean operator not
- Parentheses ( )
request.uri ~ ".*\.css"
request.uri = "/index.html"
request.method = "POST"
request.method = "GET"
etc
secure
not secure
request.content-type ~ "text/.*"
request.headers.cookie ~ ".*userid.*"
not request.headers.user-agent = "explorer"
listener.address = "localhost:8080"
We want to redirect all non secure (HTTP) GET Requests for path "/index.html" to secure ones. To do so the matching condition we need to use for a Route is:
route.0.match=not secure and request.uri ~ "/index.html" and request.method = "GET"