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 to Dapr to valid Dapr API endpoints.

Component format

The router alias middleware metadata contains name/value pairs, where the name describes the HTTP route to expect, and the value describes the corresponding Dapr API the request should be sent to.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: routeralias
  5. spec:
  6. type: middleware.http.routeralias
  7. version: v1
  8. metadata:
  9. - name: "/v1.0/mall/activity/info"
  10. value: "/v1.0/invoke/srv.default/method/mall/activity/info"
  11. - name: "/v1.0/hello/activity/{id}/info"
  12. value: "/v1.0/invoke/srv.default/method/hello/activity/info"
  13. - name: "/v1.0/hello/activity/{id}/user"
  14. value: "/v1.0/invoke/srv.default/method/hello/activity/user"

Example:

An incoming HTTP request for /v1.0/mall/activity/info?id=123 is transformed into /v1.0/invoke/srv.default/method/mall/activity/info?id=123.

Dapr configuration

To be applied, the middleware must be referenced in configuration. See middleware pipelines.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: appconfig
  5. spec:
  6. httpPipeline:
  7. handlers:
  8. - name: routeralias
  9. type: middleware.http.routeralias

Last modified February 16, 2023: Add router alias middleware (#3180) (0d3d6145)