Melkeydev / go-blueprint

Go-blueprint allows users to spin up a quick Go project using a popular framework
MIT License
2.06k stars 141 forks source link

Implement [Fiber Framework] Middleware Rate Limiter #206

Closed H0llyW00dzZ closed 1 month ago

H0llyW00dzZ commented 1 month ago

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

Implementing this rate limiter is pretty useful. I've been using it on my large RESTful APIs (500+ Handlers) with HTMX (for front end).

Description of Changes:

Checklist

H0llyW00dzZ commented 1 month ago

some ci error lmao

run golangci-lint
  Running [/home/runner/golangci-lint-1.55.2-linux-amd64/golangci-lint run --out-format=github-actions --path-prefix=fiber --timeout=5m] in [/home/runner/work/go-blueprint/go-blueprint/fiber] ...
  Error: : # fiber/internal/server
  internal/server/routes.go:9:2: time redeclared in this block
    internal/server/routes.go:4:2: other declaration of time
  internal/server/routes.go:9:2: "time" imported and not used (typecheck)
  Error: could not import fiber/internal/server (-: # fiber/internal/server
  internal/server/routes.go:9:2: time redeclared in this block
    internal/server/routes.go:4:2: other declaration of time
  internal/server/routes.go:9:2: "time" imported and not used) (typecheck)
  Error: could not import fiber/internal/server (-: # fiber/internal/server
  internal/server/routes.go:9:2: time redeclared in this block
    internal/server/routes.go:4:2: other declaration of time
  internal/server/routes.go:9:2: "time" imported and not used) (typecheck)

  Error: issues found
  Ran golangci-lint in 12550ms
H0llyW00dzZ commented 1 month ago

Any changes like this would need to be applied to all frameworks.

I haven't tested it yet for other frameworks, but currently, it works well for Fiber since it provides everything needed for web applications. Also Fiber's performance is particularly impressive for serverless applications when combined with Sonic for JSON decoding/encoding, marshaling, and unmarshaling.

briancbarrow commented 1 month ago

@H0llyW00dzZ another concern with these PRs is that go-blueprint is intended to be an un-opinionated way of setting up a boilerplate Go project. I think this and the other PRs you have opened are good ideas though.

I'll discuss with the team to decide if this is something we'd like to see. I just didn't want you to think we're ignoring your PRs.

H0llyW00dzZ commented 1 month ago

@H0llyW00dzZ another concern with these PRs is that go-blueprint is intended to be an un-opinionated way of setting up a boilerplate Go project. I think this and the other PRs you have opened are good ideas though.

I'll discuss with the team to decide if this is something we'd like to see. I just didn't want you to think we're ignoring your PRs.

@briancbarrow Yeah, it's fine. I came here to contribute so that I don't have to write the code again when using this boilerplate Go project for other RESTful APIs or front-end websites written in Go.

H0llyW00dzZ commented 1 month ago

Also it might useful for anyone who need it that, and don't have write again

briancbarrow commented 1 month ago

@H0llyW00dzZ after discussing it with @Melkeydev and @Ujstor we have decided that this feature is beyond the scope of what go-blueprint is supposed to be. It is intended to just be a scaffold from which to start projects. Users can add more robust features/middleware as they see fit.

Thanks though for your PRs. We appreciate the contribution even if it ends up not being a fit.