move limiting into foo
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package broker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"local/truckstop/config"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
@@ -15,3 +18,11 @@ var limiter = rate.NewLimiter(rate.Limit(1.0/20.0), 1)
|
||||
type Broker interface {
|
||||
Search([]config.State) ([]Job, error)
|
||||
}
|
||||
|
||||
func do(r *http.Request) (*http.Response, error) {
|
||||
limiter.Wait(context.Background())
|
||||
if strings.Contains(strings.ToLower(r.URL.Path), "login") {
|
||||
authlimiter.Wait(context.Background())
|
||||
}
|
||||
return http.DefaultClient.Do(r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user