{"id":22835169,"url":"https://github.com/jchristn/switchboard","last_synced_at":"2025-06-28T13:32:10.316Z","repository":{"id":267277924,"uuid":"897722064","full_name":"jchristn/Switchboard","owner":"jchristn","description":"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.","archived":false,"fork":false,"pushed_at":"2025-06-18T03:33:38.000Z","size":280,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T03:22:14.514Z","etag":null,"topics":["api","application","balancer","gateway","load","loadbalancer","proxy","rest","reverse","server"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jchristn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-03T05:53:52.000Z","updated_at":"2025-06-18T03:33:41.000Z","dependencies_parsed_at":"2024-12-09T12:57:43.512Z","dependency_job_id":"d601955c-2be3-4983-ae3c-c79119df7ded","html_url":"https://github.com/jchristn/Switchboard","commit_stats":null,"previous_names":["jchristn/switchboard"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jchristn/Switchboard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FSwitchboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FSwitchboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FSwitchboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FSwitchboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchristn","download_url":"https://codeload.github.com/jchristn/Switchboard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FSwitchboard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261230078,"owners_count":23127741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","application","balancer","gateway","load","loadbalancer","proxy","rest","reverse","server"],"created_at":"2024-12-12T22:08:37.074Z","updated_at":"2025-06-28T13:32:10.310Z","avatar_url":"https://github.com/jchristn.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/jchristn/switchboard/blob/main/assets/icon.png?raw=true\" width=\"140\" height=\"128\" alt=\"Switchboard\"\u003e\n\n# Switchboard\n\nSwitchboard 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.\n\n## Help, Feedback, Contribute\n\nIf 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!\n\n## New in v3.0.x\n\n- Added origin server healthchecks and ratelimiting\n\n## Default Configuration\n\nBy default, Switchboard server will listen on `http://localhost: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`.\n\nIf not explicitly set, origin servers will have their health checked along the following parameters:\n- Using `GET /`\n- Checked every five seconds (see `HealthCheckIntervalMs`)\n- Two consecutive failures (see `UnhealthyThreshold`) marks an origin server as unhealthy\n- Two consecutive successes (see `HealthyThreshold`) marks an origin server as healthy\n\nIf not explicitly set, origin server rate limiting will be enforced along the following parameters:\n- Up to 10 parallel requests can be handled at a time (see `MaxParallelRequests`) per origin server\n- Up to 30 requests can be in process and pending at a time (see `RateLimitRequestsThreshold`) per origin server\n\n## Example (Integrated)\n\nRefer to the `Test` project for a working example with one API endpoint and four origin servers.\n\n```csharp\nusing Switchboard.Core;\n\n// initialize settings\nSwitchboardSettings settings = new SwitchboardSettings();\n\n// add API endpoints\nsettings.Endpoints.Add(new ApiEndpoint\n{\n    Identifier = \"my-api-endpoint\",\n    Name = \"My API endpoint\",\n    LoadBalancing = LoadBalancingMode.RoundRobin,\n    Unauthenticated = new ApiEndpointGroup // URLs that do not require authentication via the authentication callback\n    {\n        ParameterizedUrls = new Dictionary\u003cstring, List\u003cstring\u003e\u003e\n        {\n            { \"GET\", new List\u003cstring\u003e { \"/unauthenticated\" } },\n        }\n    },\n    Authenticated = new ApiEndpointGroup // URLs that require authentication via the authentication callback\n    {\n        ParameterizedUrls = new Dictionary\u003cstring, List\u003cstring\u003e\u003e\n        {\n            { \"GET\", new List\u003cstring\u003e { \"/authenticated\" } },\n            { \"GET\", new List\u003cstring\u003e { \"/users/{UserGuid}\" } }\n        }\n    },\n    RewriteUrls = new Dictionary\u003cstring, Dictionary\u003cstring, string\u003e\u003e\n    {\n        {\n            \"GET\", new Dictionary\u003cstring, string\u003e \n            {\n                \"/users/{UserGuid}\", \"/{UserGuid}\" // rewrite /users/foo to just /foo\n            }\n        }\n    },\n    OriginServers = new List\u003cstring\u003e\n    {\n        \"my-origin-server\"\n    }\n});\n\n// add origin servers\nsettings.Origins.Add(new OriginServer\n{\n    Identifier = \"my-origin-server\",\n    Name = \"My origin server\",\n    Hostname = \"localhost\",\n    Port = 8001,\n    Ssl = false\n});\n\n// define the authentication and authorization callback\nprivate static async Task\u003cAuthContext\u003e AuthenticateAndAuthorizeRequest(HttpContextBase ctx)\n{\n    return new AuthContext\n    {\n        Authentication = new AuthenticationContext\n        {\n            Result = AuthenticationResultEnum.Success,\n            Metadata = new Dictionary\u003cstring, string\u003e() // use this object as you wish\n            {\n                { \"Authenticated\", \"true\" }\n            }\n        },\n        Authorization = new AuthorizationContext\n        {\n            Result = AuthorizationResultEnum.Success,\n            Metadata = new Dictionary\u003cstring, string\u003e() // use this object as you wish\n            {\n                { \"Authorized\", \"true\" }\n            }\n        },\n        Metadata = new Dictionary\u003cstring, string\u003e() // use this object as you wish\n        {\n            { \"Allow\", \"true\" }\n        }\n    };\n}\n\n// start Switchboard\nusing (SwitchboardDaemon sb = new SwitchboardDaemon(settings))\n{\n    sb.Callbacks.AuthenticateAndAuthorize = AuthenticateAndAuthorizeRequest;\n    ...\n}\n```\n\n## Example (Standalone)\n\n```csharp\n$ cd /path/to/src-directory\n$ dotnet build\n$ cd Switchboard.Server/bin/Debug/net8.0\n$ dotnet Switchboard.Server.dll\n\n\n            _ _      _    _                      _\n  ____ __ _(_) |_ __| |_ | |__  ___  __ _ _ _ __| |\n (_-\u003c V  V / |  _/ _| ' \\| '_ \\/ _ \\/ _` | '_/ _` |\n /__/\\_/\\_/|_|\\__\\__|_||_|_.__/\\___/\\__,_|_| \\__,_|\n\n\nSwitchboard Server v3.0.0\n\nLoading from settings file ./sb.json\n2024-12-05 03:30:01 INSPIRON-14 Info [SwitchboardDaemon] webserver started on http://localhost:8000\n2024-12-05 03:30:01 INSPIRON-14 Info [SwitchboardDaemon] Switchboard Server started using process ID 49308\n```\n\n## Docker\n\nA Docker image is available in [Docker Hub](https://hub.docker.com/r/jchristn/switchboard) under `jchristn/switchboard`.  Use the Docker Compose start (`compose-up.sh` and `compose-up.bat`) and stop (`compose-down.sh` and `compose-down.bat`) scripts in the `Docker` directory if you wish to run within Docker Compose.  Ensure that you have a valid configuration file (e.g. `sb.json`) exposed into your container.\n\n## Version History\n\nRefer to CHANGELOG.md for version history.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristn%2Fswitchboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchristn%2Fswitchboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristn%2Fswitchboard/lists"}