Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/realbucksavage/stargate
A lightweight and extensible library to build gateway servers.
https://github.com/realbucksavage/stargate
api-gateway go golang
Last synced: 12 days ago
JSON representation
A lightweight and extensible library to build gateway servers.
- Host: GitHub
- URL: https://github.com/realbucksavage/stargate
- Owner: realbucksavage
- License: mit
- Created: 2020-03-28T18:41:13.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-06T12:43:21.000Z (about 1 year ago)
- Last Synced: 2024-02-01T23:58:20.145Z (10 months ago)
- Topics: api-gateway, go, golang
- Language: Go
- Homepage:
- Size: 97.7 KB
- Stars: 20
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - stargate - A lightweight, extendable, and blazing fast API Gateway (Go)
README
[![Go Reference](https://pkg.go.dev/badge/github.com/realbucksavage/stargate.svg)](https://pkg.go.dev/github.com/realbucksavage/stargate)
[![codecov](https://codecov.io/gh/realbucksavage/stargate/branch/main/graph/badge.svg?token=QCRZ7IT8Y3)](https://codecov.io/gh/realbucksavage/stargate)
[Report Card](https://www.goreportcard.com/report/github.com/realbucksavage/stargate)# Stargate
A minimal and extensible library to build gateway servers. Stargate aims to be simple while providing niche solutions
like several load balancer implementations, middleware, service discovery, etc.Stargate supports:
- WebSockets
- Hot-reloading of routes
- Middleware[stargatecontrb](https://github.com/realbucksavage/stargatecontrib) contains some middleware implementations that are
not in the scope of this library, but might be useful for some people.## Getting started
Check the [basic example](./_examples/basic/main.go) that implements a
`stargate.ServiceLister` to create a static table of routes and uses round-robin approach to load balance the request.In the same sprits, the [WebSockets example](./_examples/websockets/main.go) shows a simple WebSocket backend.
### Customize logging
Stargate uses `stargate.Log` variable to write its logging output. This variable is an implementation
of `stargate.Logger`. You may write your own implementation of this interface and write `stargate.Log = myOwnLogger{}`
whenever your program starts.Check the [custom logger example](./_examples/logger_custom/main.go).
### Using dynamic route tables.
If the `stargate.ServiceLister`'s implementation updates the route table, the `stargate.Router` instance can be told to
update the routing by calling the `Reload()` method.Check the [reloading routes example](./_examples/reloading_router/reload.go).
#### Eureka service discovery
Check the [eureka package in stargatecontrib](https://github.com/realbucksavage/stargatecontrib/tree/main/lister/eureka).
### Middleware
Stargate defines middleware as:
```go
type MiddlewareFunc func (http.Handler) http.Handler
```Check the [middleware example](./_examples/middleware/main.go), that counts the number of requests served.
## Open TODOs
- Improve logging
- Improve documentation
- Write more tests
- Customizable healthchecks#### `LoadBalancer` implementations
- Priority round-robin