Documentation
¶
Overview ¶
Package gate allows you to limit the number of busy handlers (at the gate)
Installation ¶
Just go get the package:
go get -u github.com/TV4/gate
Usage ¶
A small usage example
package main
import (
"net/http"
"time"
"github.com/TV4/gate"
)
func index(w http.ResponseWriter, r *http.Request) {
time.Sleep(1 * time.Second)
w.Write([]byte("Hello, World!\n"))
}
func main() {
http.Handle("/", gate.HandlerFunc(index, 10))
http.ListenAndServe(":2016", nil)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BlockedHandler = http.NotFoundHandler()
BlockedHandler is the handler that is used when n < 1
Functions ¶
func HandlerFunc ¶
func HandlerFunc(h http.HandlerFunc, limit int) http.Handler
HandlerFunc takes a http.HandlerFunc and limit number
Types ¶
Click to show internal directories.
Click to hide internal directories.