Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Vapor 4 support + custom cache keys #20

Merged
merged 9 commits into from
Mar 1, 2021

Conversation

madsodgaard
Copy link
Contributor

This PR adds Vapor 4 support with the following API:

app.gatekeeper.config = .init(maxRequests: 10, per: .second)

Other than that it's possible to use a custom cache, but by default it uses the Vapor 4 in memory cache.

app.gatekeeper.caches.use(.memory)

This PR also adds GatekeeperKeyMaker which is a protocol used to define the cache key for a specific Request this solves: #3
By default it uses GatekeeperHostnameKeyMaker which uses the request hostname to generate the cache key

app.gatekeeper.keyMakers.use(.hostname)

I still need to update the README, but the code should be ready for review.

@siemensikkema
Copy link
Contributor

@madsodgaard Thank you for this well-crafted PR! I think the translation to Vapor 4 is very well done and the added customizability is more than welcome!
I checked out the code and made some small fixes in this branch https://github.com/nodes-vapor/gatekeeper/tree/feature/vapor4-PR-review. I find doing PR-reviews on such large changes a bit cumbersome. If you agree with the changes you can just merge that branch in (or cherry-pick those commits you agree with). With that the only thing really missing should be the README. Do you mind updating that to show the new syntax and features? 🙏🏻

@madsodgaard
Copy link
Contributor Author

@siemensikkema Great to hear! I'll get that branch merged and update the README within a few days.

@madsodgaard
Copy link
Contributor Author

@siemensikkema Merged your changes and updated the README. Should be ready for review!

Copy link
Contributor

@siemensikkema siemensikkema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating. We're nearly there! Just a few nits in relation to the README and I discovered that .swiftpm has been committed. Could you remove that and add .swiftpm to .gitignore?

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@madsodgaard
Copy link
Contributor Author

@siemensikkema Done 😄

Copy link
Contributor

@siemensikkema siemensikkema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much! I'll release this in a minute 👌🏻

@siemensikkema siemensikkema merged commit a9671f5 into ml-archive:master Mar 1, 2021
@madsodgaard madsodgaard deleted the vapor4 branch April 12, 2021 14:50
@siemensikkema siemensikkema mentioned this pull request Apr 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants