API proxy with several routing options.
Multiple APIs on the same port are discriminated by host, path, or a test expression. Incoming requests are probed from the top API to the bottom. The first API that matches the request will process it.
When openapi children are present, Membrane auto-wires a publisher at /api-docs and an OpenAPI rewriter; see tutorials/getting-started/80-OpenAPI.yaml and tutorials/getting-started/90-OpenAPI-Validation.yaml.
Example Configuration
api:
port: 2000
path:
uri: /orders/{id}
target:
url: https://api.predic8.de/shop/orders/{pathParam.id}
---
api:
port: 2000
path:
uri: /orders/
target:
url: https://api.predic8.de
---
api:
port: 2000
test: header.SOAPAction == 'https://predic8.de/city-service/get'
target:
url: https://api.predic8.de
---
api:
port: 2000
openapi:
- location: openapi/fruitshop-api.yaml
api:
port: 2000
path:
uri: /orders/{id}
target:
url: https://api.predic8.de/shop/orders/{pathParam.id}
---
api:
port: 2000
path:
uri: /orders/
target:
url: https://api.predic8.de
---
api:
port: 2000
test: header.SOAPAction == 'https://predic8.de/city-service/get'
target:
url: https://api.predic8.de
---
api:
port: 2000
openapi:
- location: openapi/fruitshop-api.yaml
Syntax
api:
'$ref': <string>
description: <string>
flow:
- <flow>
host: <string>
id: <string>
ip: <string>
language: groovy
method: <string>
name: <string>
openapi:
- <openapi>
path: {}
port: <number>
ssl: {}
target: {}
test: <string>
xmlConfig: {}
api:
'$ref': <string>
description: <string>
flow:
- <flow>
host: <string>
id: <string>
ip: <string>
language: groovy
method: <string>
name: <string>
openapi:
- <openapi>
path: {}
port: <number>
ssl: {}
target: {}
test: <string>
xmlConfig: {}
Attributes
| Name | Required | Default | Description | Examples |
|---|---|---|---|---|
| $ref | false | - | Reference a component defined under components. | - |
| host | false | not set | Restricts to requests whose Host header matches one of the given hostnames. Separate multiple hostnames with spaces. The asterisk * matches any number of characters, including zero, for basic globbing. | predic8.de *.predic8.de |
| id | false | - | - | - |
| ip | false | not set | If present, binds the port only on the specified IP. Useful for hosts with multiple IP addresses. | 127.0.0.1 |
| language | false | - | - | - |
| method | false | * | Restricts this proxy to requests whose HTTP method (GET, POST, etc.) matches. The asterisk * matches any method. | GET |
| name | false | By default, a name will be automatically generated from the target host, port, etc. | The name as shown in the Admin Console. | - |
| port | false | 80 | The port Membrane listens on for incoming connections. | 8080 |
| test | false | - | - | - |
Child Structure
| Element | Cardinality | Description |
|---|---|---|
| description | 0..1 | |
| flow | 0..* | |
| openapi | 0..* | Deploys an API from an OpenAPI document. |
| path | 0..1 | Restricts to requests whose path matches, either by prefix (starts-with) or, when enabled, by regular expression. In a soapProxy, setting a path also rewrites the paths of SOAP requests and the service addresses in the WSDL accordingly. |
| ssl | 0..1 | Configures inbound or outbound SSL connections. |
| target | 0..1 | The backend server that requests are forwarded to after passing through the flow. |
| xmlConfig | 0..1 |
Can be used in
No parent elements.