Vanilla Server
This page is based on the following example:
https://github.com/aileron-gateway/aileron-gateway/tree/main/examples/vanilla-server/
Vanilla Server
Overview
This example runs a vanilla server. A vanilla-server does not have any feature but returns 404 NotFound.
AILERON Gateway supports running multiple servers in a single process.
block-beta columns 3 Downstream:1 space:1 block:aileron:1 columns 1 HTTPServer1["πͺ</br>HTTP</br>Server"] οΈ HTTPServer2["πͺ</br>HTTP</br>Server"] end Downstream --> HTTPServer1 HTTPServer1 --> Downstream Downstream --> HTTPServer2 HTTPServer2 --> Downstream style Downstream stroke:#888
Legend:
- π₯
#ff6961
Handler resources. - π©
#77dd77
Middleware resources (Server-side middleware). - π¦
#89CFF0
Tripperware resources (Client-side middleware). - πͺ
#9370DB
Other resources.
In this example, following directory structure and files are supposed. If you need a pre-built binary, download from GitHub Releases.
vanilla-server/ ----- Working directory.
βββ aileron ----- AILERON Gateway binary (aileron.exe on windows).
βββ config-single.yaml ----- AILERON Gateway config file for single server.
βββ config-multiple.yaml ----- AILERON Gateway config file for multiple servers.
Config
Configuration yaml to run multiple vanilla servers would becomes as follows. Config for a single server would be more simple than this (See the config-single.yaml).
# config-multiple.yaml
apiVersion: core/v1
kind: Entrypoint
spec:
runners:
- apiVersion: core/v1
kind: HTTPServer
name: server1
- apiVersion: core/v1
kind: HTTPServer
name: server2
- apiVersion: core/v1
kind: HTTPServer
name: server3
---
apiVersion: core/v1
kind: HTTPServer
metadata:
name: server1
spec:
addr: ":8081"
---
apiVersion: core/v1
kind: HTTPServer
metadata:
name: server2
spec:
addr: ":8082"
---
apiVersion: core/v1
kind: HTTPServer
metadata:
name: server3
spec:
addr: ":8083"
The config tells:
- Start 3
HTTPServer
with port 8081, 8082 and 8083. - Each server has their name
server1
,server2
andserver3
. - No other features are applied.
This graph shows the resource dependencies of the configuration.
graph TD Entrypoint["πͺ **Entrypoint**</br>default/default"] HTTPServer1["πͺ **HTTPServer**</br>default/server1"] HTTPServer2["πͺ **HTTPServer**</br>default/server2"] HTTPServer3["πͺ **HTTPServer**</br>default/server3"] Entrypoint --"Runner"--> HTTPServer1 Entrypoint --"Runner"--> HTTPServer2 Entrypoint --"Runner"--> HTTPServer3
Run
Run the AILERON Gateway with command:
./aileron -f ./config-multiple.yaml
Check
After running servers, send HTTP requests to it.
A json response will be returned when the vanilla servers are correctly running. Note that the vanilla servers returns 404 NotFound because no handlers are registered to them.
$ curl http://localhost:8081
{"status":404,"statusText":"Not Found"}
$ curl http://localhost:8082
{"status":404,"statusText":"Not Found"}
$ curl http://localhost:8083
{"status":404,"statusText":"Not Found"}
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.