Router alias http request routing
Use router alias middleware to alias arbitrary http routes to Dapr endpoints
The router alias HTTP middleware component allows you to convert arbitrary HTTP routes arriving into Dapr to valid Dapr API endpoints.
Component format
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: routeralias
spec:
type: middleware.http.routeralias
version: v1
metadata:
# String containing a JSON-encoded or YAML-encoded dictionary
# Each key in the dictionary is the incoming path, and the value is the path it's converted to
- name: "routes"
value: |
{
"/mall/activity/info": "/v1.0/invoke/srv.default/method/mall/activity/info",
"/hello/activity/{id}/info": "/v1.0/invoke/srv.default/method/hello/activity/info",
"/hello/activity/{id}/user": "/v1.0/invoke/srv.default/method/hello/activity/user"
}
In the example above, an incoming HTTP request for /mall/activity/info?id=123
is transformed into /v1.0/invoke/srv.default/method/mall/activity/info?id=123
.
Spec metadata fields
Field | Details | Example |
---|---|---|
routes |
String containing a JSON-encoded or YAML-encoded dictionary. Each key in the dictionary is the incoming path, and the value is the path it’s converted to. | See example above |
Dapr configuration
To be applied, the middleware must be referenced in configuration. See middleware pipelines.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
httpPipeline:
handlers:
- name: routeralias
type: middleware.http.routeralias
Related links
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified May 31, 2024: Merge 61e65296a85dd35c3b7040b281b7c17caffcc144 into 27b6a61b0e1b0a30ea4e4f31bea712dfec3813b3 (525f2ab)