1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-26 20:54:00 +02:00
Commit Graph

17 Commits

Author SHA1 Message Date
Benjamin Chibuzor-Orie
7c8592a7e0
adds middleware for rate limiting (#1724)
* adds middleware for rate limiting

* added comment for InMemoryStore ShouldAllow

* removed redundant mutex declaration

* fixed lint issues

* removed sleep from tests

* improved coverage

* refactor: renames Identifiers, includes default SourceFunc

* Added last seen stats for visitor

* uses http Constants for improved readdability
adds default error handler

* used other handler apart from default handler to mark custom error handler for rate limiting

* split tests into separate blocks
added an error pair to IdentifierExtractor
Includes deny handler for explicitly denying requests

* adds comments for exported members Extractor and ErrorHandler

* makes cleanup implementation inhouse

* Avoid race for cleanup due to non-atomic access to store.expiresIn

* Use a dedicated producer for rate testing

* tidy commit

* refactors tests, implicitly tests lastSeen property on visitor
switches NewRateLimiterMemoryStore constructor to Referential Functions style (Advised by @pafuent)

* switches to mock of time module for time based tests
tests are now fully deterministic

* improved coverage

* replaces Rob Pike referential options with more conventional struct configs
makes cleanup asynchronous

* blocks racy access to lastCleanup

* Add benchmark tests for rate limiter

* Add rate limiter with sharded memory store

* Racy access to store.lastCleanup eliminated
Merges in shiny sharded map implementation by @lammel

* Remove RateLimiterShradedMemoryStore for now

* Make fields for RateLimiterStoreConfig public for external configuration

* Improve docs for RateLimiter usage

* Fix ErrorHandler vs. DenyHandler usage for rate limiter

* Simplify NewRateLimiterMemoryStore

* improved coverage

* updated errorHandler and denyHandler to use echo.HTTPError

* Improve wording for error and comments

* Remove duplicate lastSeen marking for Allow

* Improve wording for comments

* Add disclaimer on perf characteristics of memory store

* changes Allow signature on rate limiter to return err too

Co-authored-by: Roland Lammel <rl@neotel.at>
2021-01-15 17:53:15 -03:00
Vishal Rana
c7531df815 Fixed build
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-06-28 19:08:45 -07:00
Vishal Rana
1b70cbebbe Fixed #954
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-06-14 16:30:53 -07:00
Vishal Rana
7834248244 Updated ci
Signed-off-by: Vishal Rana <vishal.rana@verizon.com>
2017-06-07 11:48:06 -07:00
Vishal Rana
10809fad77 Fixed build
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-05-11 14:55:11 -07:00
Vishal Rana
d832efd403 cors: not checking for origin header
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-11-12 14:05:41 -08:00
Vishal Rana
9c864319d3 updated .gitignore
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-01 21:08:54 -07:00
Vishal Rana
467cf05b41 Changes based on comments for #430
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-04-16 15:56:09 -07:00
Vishal Rana
e1d789ecbb Logger as not an interface
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-03-06 09:52:32 -08:00
Vishal Rana
e619a97607 Removed Makefile
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-11-01 12:16:37 -08:00
Vishal Rana
c60f207279 Added JSONP recipe
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-10-07 16:46:03 -07:00
Vishal Rana
c020919cb4 Updated website
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-10-01 18:24:38 -07:00
Vishal Rana
9b36defadf Updated .gitignore
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-08-29 11:26:06 -07:00
Vishal Rana
e43aa31e01 Echo header with URL
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-29 22:02:13 -07:00
Vishal Rana
54824fc22f Added gulp to website
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-18 22:27:30 -07:00
Vishal Rana
141b4302ae Created a website #29
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-18 21:53:38 -07:00
Vishal Rana
99124cda0a Wrap method for using third party middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-03-21 14:59:09 -07:00