Skip to content

Commit 0d3d614

Browse files
yaron2msfussell
andauthored
Add router alias middleware (#3180)
* Add router alias middleware Signed-off-by: yaron2 <schneider.yaron@live.com> * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-routeralias.md Signed-off-by: Mark Fussell <markfussell@gmail.com> * Update daprdocs/content/en/reference/components-reference/supported-middleware/middleware-routeralias.md Signed-off-by: Mark Fussell <markfussell@gmail.com> --------- Signed-off-by: yaron2 <schneider.yaron@live.com> Signed-off-by: Mark Fussell <markfussell@gmail.com> Co-authored-by: Mark Fussell <markfussell@gmail.com>
1 parent bf0950a commit 0d3d614

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
type: docs
3+
title: "Router alias http request routing"
4+
linkTitle: "Router Alias"
5+
description: "Use router alias middleware to alias arbitrary http routes to Dapr endpoints"
6+
aliases:
7+
- /developing-applications/middleware/supported-middleware/middleware-routeralias/
8+
---
9+
10+
The router alias HTTP [middleware]({{< ref middleware.md >}}) component allows you to convert arbitrary HTTP routes arriving to Dapr to valid Dapr API endpoints.
11+
12+
## Component format
13+
14+
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.
15+
16+
```yaml
17+
apiVersion: dapr.io/v1alpha1
18+
kind: Component
19+
metadata:
20+
name: routeralias
21+
spec:
22+
type: middleware.http.routeralias
23+
version: v1
24+
metadata:
25+
- name: "/v1.0/mall/activity/info"
26+
value: "/v1.0/invoke/srv.default/method/mall/activity/info"
27+
- name: "/v1.0/hello/activity/{id}/info"
28+
value: "/v1.0/invoke/srv.default/method/hello/activity/info"
29+
- name: "/v1.0/hello/activity/{id}/user"
30+
value: "/v1.0/invoke/srv.default/method/hello/activity/user"
31+
```
32+
33+
Example:
34+
35+
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`.
36+
37+
## Dapr configuration
38+
39+
To be applied, the middleware must be referenced in [configuration]({{< ref configuration-concept.md >}}). See [middleware pipelines]({{< ref "middleware.md#customize-processing-pipeline">}}).
40+
41+
```yaml
42+
apiVersion: dapr.io/v1alpha1
43+
kind: Configuration
44+
metadata:
45+
name: appconfig
46+
spec:
47+
httpPipeline:
48+
handlers:
49+
- name: routeralias
50+
type: middleware.http.routeralias
51+
```
52+
53+
## Related links
54+
55+
- [Middleware]({{< ref middleware.md >}})
56+
- [Configuration concept]({{< ref configuration-concept.md >}})
57+
- [Configuration overview]({{< ref configuration-overview.md >}})

daprdocs/data/components/middleware/http.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
state: Alpha
3434
version: v1
3535
description: Use RouterChecker middleware to block invalid http request routing
36+
- component: Router Alias
37+
link: /reference/components-reference/supported-middleware/middleware-routeralias
38+
state: Alpha
39+
version: v1
40+
description: Use Router Alias to map arbitrary HTTP routes to valid Dapr API endpoints
3641
- component: Uppercase
3742
link: /reference/components-reference/supported-middleware/middleware-uppercase
3843
state: Stable

0 commit comments

Comments
 (0)