jchristn/switchboard
Lightweight application proxy combining reverse proxy and API gateway functionality.
292
Switchboard is a lightweight application proxy combining reverse proxy and API gateway functionality. Switchboard can be integrated directly into your app or run as a standalone server.
If you have any issues or feedback, please file an issue here in Github. We'd love to have you help by contributing code for new features, optimization to the existing codebase, ideas for future releases, or fixes!
By default, Switchboard server will listen on port 8000
and is not configured with API endpoints or origin servers (see below for an example). If you point your browser to http://localhost:8000/
you will see a default page indicating that the node is operational. HEAD
requests to this URL will also return a 200/OK
.
Refer to the Test
project for a working example with one API endpoint and two origin servers.
using Switchboard.Core;
// initialize settings
SwitchboardSettings settings = new SwitchboardSettings();
// add API endpoints
settings.Endpoints.Add(new ApiEndpoint
{
Identifier = "my-api-endpoint",
Name = "My API endpoint",
LoadBalancing = LoadBalancingMode.RoundRobin,
ParameterizedUrls = new Dictionary<string, List<string>>
{
{ "GET", new List<string> { "/my-api" } }
},
OriginServers = new List<string>
{
"my-origin-server"
}
});
// add origin servers
settings.Origins.Add(new OriginServer
{
Identifier = "my-origin-server",
Name = "My origin server",
Hostname = "localhost",
Port = 8001,
Ssl = false
});
// start Switchboard
using (SwitchboardDaemon sb = new SwitchboardDaemon(settings))
{
...
}
$ cd /path/to/src-directory
$ dotnet build
$ cd Switchboard.Server/bin/Debug/net8.0
$ dotnet Switchboard.Server.dll
_ _ _ _ _
____ __ _(_) |_ __| |_ | |__ ___ __ _ _ _ __| |
(_-< V V / | _/ _| ' \| '_ \/ _ \/ _` | '_/ _` |
/__/\_/\_/|_|\__\__|_||_|_.__/\___/\__,_|_| \__,_|
Switchboard Server v1.0.0
Loading from settings file ./sb.json
2024-12-05 03:30:01 INSPIRON-14 Info [SwitchboardDaemon] webserver started on http://localhost:8000
2024-12-05 03:30:01 INSPIRON-14 Info [SwitchboardDaemon] Switchboard Server started using process ID 49308
Refer to Github for source code and version history.
docker pull jchristn/switchboard