|
Hello I would like to know how to enable rate limits. Maybe there is a way with the library or I will have to go the normal net.http route. By the way thanks for the great library. |
Replies: 4 comments 2 replies
|
I open to look into it in a PR if there is no a simple way to do it at the moment |
|
I'm not quite sure what you're asking. This is for client requests, not server handling. You can pass in an http.RoundTripper to use, which means you can set the limit := make(chan bool, 10)
var myTransport requests.RoundTripFunc = func(req *http.Request) (res *http.Response, err error) {
limit <- true
res, err = http.DefaultTransport(req)
<-limit
return res, err
}
err := requests.
URL(url).
Transport(myTransport).
Fetch(ctx)For more complicated limiting, see this blog post for some general thoughts about managing concurrency in Go. |
|
It is not hard to do it using the library. I was asking whether it is something we have already or we can incorporate into the library. |
|
Ok thanks for the time. |
Ok thanks for the time.