On Fri, Feb 2, 2018 at 1:28 PM, Henrik Johansson <dahankz...@gmail.com>
wrote:

> You can either use one of the existing other routers that have meddleware
> support or you could wrap your handlers in another handler much like this:
>
> handle("/foo",wrapHandler(rateLimiter, realHandler))
>
> func wrapHandler(limit *ARateLimiter, handler func(http.ResponseWriter,
> *http.Request)) func(http.ResponseWriter, *http.Request){
>       return func(w http.ResponseWriter, r *http.Request) {
>                    limit.Aquire() //Or however you use the limiter
>                    handle(w,r)
>      }
> }
>
> Very rudimentary and simplified but could perhaps work. You can wrap any
> handler in the same way with either a shared limiter or one per call or any
> combination.
>

Feels like your limit parameter is simply a semaphore to me. I'll try that
for now. Thanks a lot for your help, it was most illuminating!

// Patrik

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to