Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/creack/goproxy
GoProxy is a ReverseProxy / LoadBalancer helper for Golang
https://github.com/creack/goproxy
Last synced: about 1 month ago
JSON representation
GoProxy is a ReverseProxy / LoadBalancer helper for Golang
- Host: GitHub
- URL: https://github.com/creack/goproxy
- Owner: creack
- License: mit
- Created: 2015-07-12T16:52:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-11-26T02:52:26.000Z (about 4 years ago)
- Last Synced: 2024-10-29T06:06:54.960Z (2 months ago)
- Language: Go
- Size: 11.7 KB
- Stars: 176
- Watchers: 12
- Forks: 30
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goproxy
GoProxy is a ReverseProxy / LoadBalancer helper for Golang# Example
```go
package mainimport (
"fmt"
"log"
"net/http""github.com/creack/goproxy"
"github.com/creack/goproxy/registry"
)// ServiceRegistry is a local registry of services/versions
var ServiceRegistry = registry.DefaultRegistry{
"service1": {
"v1": {
"localhost:9091",
"localhost:9092",
},
},
}func main() {
http.HandleFunc("/", goproxy.NewMultipleHostReverseProxy(ServiceRegistry))
http.HandleFunc("/health", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "%v\n", ServiceRegistry)
})
println("ready")
log.Fatal(http.ListenAndServe(":9090", nil))
}
```# Limitations
Because we control only the connection, we can't have different http routes accross the same service.
For the same reason, we can't have both HTTP and HTTPS for the same service.
For now, this load balancer only supports HTTP.