Skip to content

Route

A Route in Sushi Gateway defines how requests are handled for a specific API path. Routes determine the flow of traffic, specifying the backend service and applying necessary plugins or rules.

Fields in a Route

A Route configuration consists of the following fields:

FieldTypeDescription
nameStringA unique identifier for the route.
pathStringThe URL path that this route matches.
methodsArray of StringsThe HTTP methods supported by this route (e.g., GET, POST).
pluginsPlugin[]A list of plugins applied to this route for authentication, rate limiting, etc.

Example Configuration

Here’s an example of a route definition in config.json:

json
{
  "name": "example-route",
  "path": "/v1/sushi",
  "methods": ["GET", "POST"],
  "plugins": [
    {
      "name": "rate_limit",
      "enabled": true,
      "config": {
        "limit_second": 10,
        "limit_min": 100,
        "limit_hour": 1000
      }
    }
  ]
}

Key Fields Explained

  1. name:

    • A unique identifier for the route.
    • Example: "example-route".
  2. path:

    • Specifies the URL path that the route matches.
    • Example: "/v1/sushi" matches requests to /v1/sushi.
  3. methods:

    • Defines the HTTP methods that this route supports.
    • Example: ["GET", "POST"] allows both GET and POST requests.
  4. plugins:

    • Applies additional functionalities to the route, such as rate limiting or authentication.
    • Example:
      json
      {
        "name": "rate_limit",
        "enabled": true,
        "config": {
          "limit_second": 10,
          "limit_min": 100,
          "limit_hour": 1000
        }
      }

    TIP

    Explore all available plugins in the Plugins Overview page for more information.

Relationships with Other Entities

Routes are associated with the following entities:

  • Service: Routes belong to a service and determine how requests are forwarded to upstreams.
  • Plugin: Plugins enhance route functionality by adding features like authentication or traffic shaping.

The Route entity is crucial for managing traffic flow in Sushi Gateway. To understand other entities, see:

Released under the MIT License.