tylermmorton / torque

`torque` is a web framework for building hypermedia driven applications in Go
https://lbft.dev/
36 stars 3 forks source link

Feature: Rate Limiting for Route Modules #3

Closed tylermmorton closed 3 months ago

tylermmorton commented 10 months ago

Problem:

I often find myself configuring a rate-limiter guard for every route I register with a torque app. I think this is a good use case for the Guard API but if users end up registering the same guard on all of their endpoints, perhaps that is a sign that the guard logic should be implemented internally to torque.

torque.WithRouteModule("/login",
    &login.RouteModule{
        AuthService: authService,
    },
    torque.WithGuard(guards.ThrottleGuard(
        throttled.PerHour(25),
    )),
),

Rough outline of solution

shashank73744 commented 10 months ago

I want to work on this issue.

shashank73744 commented 10 months ago

I have one question. Do you want it to be per user or overall ?

tylermmorton commented 10 months ago

Hi @shashank73744! Thanks for taking this on. That is a great question. Currently torque does not have the concept of a user or session. We'll have to lean on identifiers sent via incoming HTTP requests, such as IP address or user agent string. I think picking one of those two would be a great start. Let me know if you need help or have other questions!