mirror of https://github.com/dapr/docs.git
Merge branch 'v1.12' into bulk_pubsub_optimization_paths
This commit is contained in:
commit
be1936c84c
|
@ -7,12 +7,10 @@ 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.
|
||||
The router alias HTTP [middleware]({{< ref middleware.md >}}) component allows you to convert arbitrary HTTP routes arriving into 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
|
||||
|
@ -22,17 +20,24 @@ 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"
|
||||
# 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"
|
||||
}
|
||||
```
|
||||
|
||||
Example:
|
||||
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`.
|
||||
|
||||
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`.
|
||||
# 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue