Created
August 8, 2017 23:00
-
-
Save fireproofsocks/4ba9799162838e81efd1eeda54135041 to your computer and use it in GitHub Desktop.
Express Gateway Example connecting to 2 different services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http: | |
port: 8080 | |
admin: | |
port: 9876 | |
hostname: localhost | |
apiEndpoints: | |
ip: | |
host: localhost | |
paths: '/ip' | |
randomQuote: | |
host: localhost | |
paths: '/random/quote' | |
serviceEndpoints: | |
# names, ref'd by pipelines | |
httpbin: | |
url: 'https://httpbin.org' | |
quotes: | |
url: 'http://quotes.rest' | |
policies: | |
- expression | |
- proxy | |
pipelines: | |
# This pipeline executes a simple proxy, where a path that exists on the remote service is handled locally by our | |
# API service. | |
- name: ip | |
apiEndpoints: | |
- ip # this needs to reference a key under the "apiEndpoints" | |
policies: | |
# Note: the path of the API request is appended to the service endpoint by default by the proxy policy | |
- proxy: | |
- action: | |
serviceEndpoint: httpbin # This needs to ref a key under "serviceEndpoints" | |
changeOrigin: true | |
# The following pipeline demonstrates how we can define one apiEndpoint locally and forward it to a completely | |
# different path on a remote server. | |
- name: quotes | |
apiEndpoints: | |
- randomQuote # this needs to reference a key under the "apiEndpoints" | |
policies: | |
- expression: # policy name | |
- action: # array of condition/actions objects | |
jscode: 'req.url = "/qod.json?category=inspire"; ' # code to execute against EG Context | |
- proxy: | |
- action: | |
serviceEndpoint: quotes | |
changeOrigin: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment