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>
This commit is contained in:
Yaron Schneider 2023-02-16 05:25:34 +00:00 committed by GitHub
parent bf0950ae42
commit 0d3d614574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,57 @@
---
type: docs
title: "Router alias http request routing"
linkTitle: "Router Alias"
description: "Use router alias middleware to alias arbitrary http routes to Dapr endpoints"
aliases:
- /developing-applications/middleware/supported-middleware/middleware-routeralias/
---
The router alias HTTP [middleware]({{< ref middleware.md >}}) 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.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: routeralias
spec:
type: middleware.http.routeralias
version: v1
metadata:
- name: "/v1.0/mall/activity/info"
value: "/v1.0/invoke/srv.default/method/mall/activity/info"
- name: "/v1.0/hello/activity/{id}/info"
value: "/v1.0/invoke/srv.default/method/hello/activity/info"
- name: "/v1.0/hello/activity/{id}/user"
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]({{< ref configuration-concept.md >}}). See [middleware pipelines]({{< ref "middleware.md#customize-processing-pipeline">}}).
```yaml
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
httpPipeline:
handlers:
- name: routeralias
type: middleware.http.routeralias
```
## Related links
- [Middleware]({{< ref middleware.md >}})
- [Configuration concept]({{< ref configuration-concept.md >}})
- [Configuration overview]({{< ref configuration-overview.md >}})

View File

@ -33,6 +33,11 @@
state: Alpha
version: v1
description: Use RouterChecker middleware to block invalid http request routing
- component: Router Alias
link: /reference/components-reference/supported-middleware/middleware-routeralias
state: Alpha
version: v1
description: Use Router Alias to map arbitrary HTTP routes to valid Dapr API endpoints
- component: Uppercase
link: /reference/components-reference/supported-middleware/middleware-uppercase
state: Stable