Skip to content

Instantly share code, notes, and snippets.

@kasvith
Created November 9, 2019 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasvith/1dd7e2b84b10552aa48f910985986454 to your computer and use it in GitHub Desktop.
Save kasvith/1dd7e2b84b10552aa48f910985986454 to your computer and use it in GitHub Desktop.
// lb load balances the incoming request
func lb(w http.ResponseWriter, r *http.Request) {
peer := serverPool.GetNextPeer()
if peer != nil {
peer.ReverseProxy.ServeHTTP(w, r)
return
}
http.Error(w, "Service not available", http.StatusServiceUnavailable)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment