# Refined Routing

API7 will triage the matched requests according to the preset weights and parameters.

## Triage by weight[​](#triage-by-weight "Triage by weight的直接链接")

The administrator creates each upstream object through the control panel, and during the configuration process, allows to set the weight value for each upstream service instance, if the value is 0, it means that no traffic is assigned to the example. In addition, upstream supports algorithms such as round robin polling with weight, chash, and exponentially weighted moving average (EWMA).

## Streaming by parameters[​](#streaming-by-parameters "Streaming by parameters的直接链接")

The API gateway supports triage based on each parameter of the request and its value, for example:

### Request Header[​](#request-header "Request Header的直接链接")

```
{

    "vars": [["http_user_agent", "~*", "android"]], // Whether request header User-Agent matches android

    "uri": "/hello",

    "upstream_id": "1"

}
```

### Request Host[​](#request-host "Request Host的直接链接")

```
{

    "hosts": ["www.my.com"], // Whether host matches "www.my.com"

    "uri": "/hello",

    "upstream_id": "1"

}
```

### Request Path[​](#request-path "Request Path的直接链接")

```
{

    "uri": "/hello", // Whether path matches "/hello"

    "upstream_id": "1"

}
```

### Request Query String[​](#request-query-string "Request Query String的直接链接")

```
{

    "vars": [["arg_theme", "==", "light"]], // Whether theme in query string matches light

    "uri": "/hello",

    "upstream_id": "1"

}
```

### Request Cookie[​](#request-cookie "Request Cookie的直接链接")

```
{

    "vars": [["cookie_token", "==", "1234"]], // Whether token field in cookie matches "1234" 

    "uri": "/hello",

    "upstream_id": "1"

}
```

When the request is matched with each parameter, the traffic will be assigned to the corresponding upstream service.
