Files
goma-gateway/docs/quickstart/route.md

151 lines
2.9 KiB
Markdown
Raw Normal View History

2024-11-02 12:01:29 +01:00
---
2024-11-09 15:06:09 +01:00
title: Route
2024-11-02 12:01:29 +01:00
layout: default
2024-11-09 15:06:09 +01:00
parent: Quickstart
2024-11-10 08:15:47 +01:00
nav_order: 2
2024-11-02 12:01:29 +01:00
---
2024-11-09 15:06:09 +01:00
# Route
2024-11-02 12:01:29 +01:00
2024-11-09 15:06:09 +01:00
The Route allows you to match on HTTP traffic and direct it to the backend.
2024-11-02 12:01:29 +01:00
### Simple route
2024-11-02 12:01:29 +01:00
2024-11-07 00:00:58 +01:00
```yaml
2024-11-10 08:15:47 +01:00
version: 1.0
2024-11-09 15:06:09 +01:00
gateway:
...
2024-11-09 15:06:09 +01:00
routes:
2024-11-07 00:00:58 +01:00
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
cors: {}
```
### Route with limited HTTP methods
The proxy will allow all HTTP methods if there's no defined method.
Example of route with limited HTTP methods allowed for a particular route.
```yaml
version: 1.0
gateway:
...
routes:
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
methods: [PATCH, GET]
2024-11-07 00:00:58 +01:00
cors: {}
middlewares:
- api-forbidden-paths
- jwt-auth
```
### Route with healthcheck
Example of route with backend health check.
2024-11-02 12:01:29 +01:00
```yaml
version: 1.0
2024-11-02 12:01:29 +01:00
gateway:
...
2024-11-02 12:01:29 +01:00
routes:
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
methods: [PATCH, GET]
healthCheck:
path: "/health/live"
interval: 0
timeout: 0
healthyStatuses: [200,404]
cors: {}
```
### Route with middleware
Example of route with backend health check.
```yaml
version: 1.0
gateway:
...
routes:
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
methods: []
healthCheck:
path: "/health/live"
interval: 0
timeout: 0
healthyStatuses: [200,404]
cors: {}
## Middleware
2024-11-02 12:01:29 +01:00
middlewares:
- api-forbidden-paths
- jwt-auth
```
### Route with backend errors interceptor
Example of route with backend errors interceptor.
```yaml
version: 1.0
gateway:
...
routes:
- name: Example
path: /store/cart
rewrite: /cart
destination: http://cart-service:8080
methods: []
2024-11-02 12:01:29 +01:00
healthCheck:
path: "/health/live"
interval: 0
timeout: 0
healthyStatuses: [200,404]
interceptErrors: [403,500]
blockCommonExploits: false
2024-11-02 12:01:29 +01:00
cors: {}
## Middleware
2024-11-05 20:48:20 +01:00
middlewares:
- api-forbidden-paths
- jwt-auth
```
### Route with enabled load balancing
Example of route with load balancing enabled.
```yaml
version: 1.0
gateway:
...
routes:
- name: Example
path: /store/cart
rewrite: /cart
## destination: will be override by backends
destination: ""
backends:
- https://example.com
- https://example2.com
- https://example4.com
methods: []
healthCheck:
path: "/health/live"
interval: 0
timeout: 0
healthyStatuses: [200,404]
interceptErrors: [403,500]
blockCommonExploits: false
cors: {}
## Middleware
middlewares:
- api-forbidden-paths
- jwt-auth
2024-11-02 12:01:29 +01:00
```