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

472 Commits

Author SHA1 Message Date
Ingo Oppermann
42f07ed880
gzip response only if it exceeds a minimal length (#2267)
* gzip response only if it exceeds a minimal length

If the response is too short, e.g. a few bytes, compressing the
response makes it even larger. The new parameter MinLength to the
GzipConfig struct allows to set a threshold (in bytes) as of which
response size the compression should be applied. If the response
is shorter, no compression will be applied.
2023-05-31 08:53:33 +03:00
toimtoimtoim
8e425c0431 gofmt fixes to comments 2023-05-12 22:14:29 +03:00
mikemherron
0ae74648b9
Support retries of failed proxy requests (#2414)
Support retries of failed proxy requests
2023-05-12 20:36:24 +03:00
Simba Peng
de1c798143 Check whether is nil before invoking centralized error handling. 2023-04-15 21:48:33 +03:00
imxyb
c0bc886b78 refactor: use strings.ReplaceAll directly 2023-03-31 20:59:08 +03:00
Becir Basic
5b36ce3612
Fixes the concurrency issue of calling the Next() proxy target on RRB (#2409)
* Fixes the concurrency issue of calling the `Next()` proxy target on round robin balancer

- fixed concurrency issue in `AddTarget()`
- moved `rand.New()` to the random balancer initializer func.
- internal code reorganized eliminating unnecessary pointer redirection
- employing `sync.Mutex` instead of `RWMutex` which brings additional overhead of tracking readers and writers. No need for that since the guarded code has no long-running operations, hence no realistic congestion.
- added additional guards without which the code would otherwise panic (e.g., the case where a random value is calculation when targets list is empty)
- added descriptions for func return values, what to expect in which case.
- Improve code test coverage

---------

Co-authored-by: Becir Basic <bb@neotel.at>
2023-02-24 20:32:41 +02:00
Omkar
1e575b7b56
Added a optional config variable to disable centralized error handler in recovery middleware (#2410)
Added a config variable to disable centralized error handler in recovery middleware
2023-02-24 13:09:40 +02:00
toimtoimtoim
f909660bb9 Add middleware.CORSConfig.UnsafeWildcardOriginWithAllowCredentials to make UNSAFE usages of wildcard origin + allow cretentials less likely. 2023-02-22 00:05:31 +02:00
toimtoimtoim
ef4aea97ef use different variable name so returned function would not accidentally be able to use it in future and cause data race 2023-02-22 00:05:31 +02:00
Martti T
7c7531002d
Clean on go1.20 (#2406)
* Fix tests failing on Go 1.20 on Windows. Clean works differently on 1.20. Use path.Clean instead with some workaround related to errors.
2023-02-22 00:00:52 +02:00
toimtoimtoim
2c25767e45 remediate flaky timeout tests 2023-02-19 20:26:17 +02:00
Hakan Kutluay
82a964c657
Add context timeout middleware (#2380)
Add context timeout middleware


Co-authored-by: Erhan Akpınar <erhan.akpinar@yemeksepeti.com>
Co-authored-by: @erhanakp
2023-02-01 22:38:20 +02:00
toimtoimtoim
a69727e2b9 Mark JWT middleware deprecated 2022-12-27 21:59:53 +02:00
yagikota
895121d178
Fix rate limiter docs (#2366)
* Improve wording for the comment of Burst
* Improve rate limiter docs
2022-12-17 11:16:00 +02:00
Kanji Yomoda
135c511f5d
Add request route with "route" tag to logger middleware (#2162) 2022-12-04 19:38:45 +01:00
Martti T
8d4ac4c907
Additional configuration options for RequestLogger and Logger middleware (#2341)
* Add `middleware.RequestLoggerConfig.HandleError` configuration option to handle error within middleware with global error handler thus setting response status code decided by error handler and not derived from error itself.
* Add `middleware.LoggerConfig.CustomTagFunc` so Logger middleware can add custom text to logged row.
2022-11-30 15:47:23 +02:00
Martti T
466bf80e41
Add testcases for some BodyLimit middleware configuration options (#2350)
* Add testcases for some BodyLimit middleware configuration options
2022-11-25 13:27:52 +02:00
toimtoimtoim
a0c211542c Add staticcheck to CI flow 2022-11-21 16:26:13 +02:00
zeek
3c4d3b3083 Replace "io/ioutil"
"io/ioutil" pakcage has been deprecated since Go 1.16.
2022-11-21 15:59:14 +02:00
wanghaha-dev
fd2b102d3e Modify comment syntax error 2022-11-12 23:56:47 +02:00
toimtoimtoim
35184a893b Expose middleware.CreateExtractors function so we can use it from echo-contrib repository 2022-11-12 23:34:04 +02:00
Hristo Hristov
0ce73028d0
[suggestion] Add helper interface for ProxyBalancer interface (#2316)
* [suggestion] Add helper interface for ProxyBalancer interface

* Update proxy_test.go

* addressed code review comments

* address pr comments

* clean up

* return error
2022-10-29 21:54:23 +03:00
Martti T
1d5f335f40
refactor assertions (#2301) 2022-10-12 21:47:21 +03:00
Daniel Price
50e7e569f0 Improve CORS documentation
* Provide links to further reading
* Provide security warnings
* Document undocumented wildcard feature
* Update to go-1.19 style links
2022-09-12 22:46:13 +03:00
toimtoimtoim
0ac4d74402 Fix #2259 open redirect vulnerability in echo.StaticDirectoryHandler (used by e.Static, e.StaticFs etc)
remove pre Go1.16 and after differences
2022-09-04 22:50:54 +03:00
Mojtaba Arezoumand
d77e8c09b2
Added ErrorHandler and ErrorHandlerWithContext in CSRF middleware (#2257)
* feat: add error handler to csrf middleware

Co-authored-by: Mojtaba Arezoomand <mojtaba.arezoomand@snapp.cab>
2022-09-01 10:51:55 +03:00
Daniel Price
a9879ffa6b Middlewares should use errors.As() instead of type assertion on HTTPError
- Helps consumers who want to wrap HTTPError, and other use cases
2022-07-21 21:24:18 +03:00
moznion
ddb66e1ba2
Add logger middleware template variables: ${time_unix_milli} and ${time_unix_micro} (#2206)
This patch introduces two template variables `${time_unix_milli}` and
`${time_unix_micro}` into the logger middleware.
Currently, there is no way to interpolate that UNIX milli and micro
seconds timestamp in a log entry, and go 1.17 or later runtime supports
the utility functions `time#UnixMilli()` and `time#UnixMicro()`
so this patch adds them as well.

see also: https://github.com/golang/go/issues/44196

Signed-off-by: moznion <moznion@mail.moznion.net>
2022-07-05 07:57:39 +03:00
welling guzmán
b0453b98e0
fix: basic auth invalid base64 string (#2191)
* fix: basic auth returns 400 on invalid base64 string
2022-05-27 19:44:51 +03:00
Martti T
d5f883707b
Timeout mw: rework how test waits for timeout. Using sleep as delay i… (#2187)
* Timeout mw: rework how test waits for timeout. Using sleep as delay is problematic when CI worker is slower than usual.
2022-05-22 00:21:50 +03:00
toimtoimtoim
28797c761d Timeout mw: fix datarace in tests when we are getting data from buffer (in test) and writing to logger at the same time. 2022-05-21 22:26:56 +03:00
toimtoimtoim
2e02ce3dd8 Timeout mw: fix datarace in tests when we are getting data from buffer. Run each test in their own server so multiple tests cases will not cause datarace getting data out of logger buffer. 2022-05-21 20:12:32 +03:00
gemaizi
572466d928 Fix body_limit middleware unit test 2022-04-05 20:34:49 +03:00
toimtoimtoim
1919cf4491 Timeout middleware write race 2022-03-16 08:09:29 +02:00
Martti T
01d7d01bbc
Fix CSRF middleware not being able to extract token from multipart/form-data form (#2136, fixes #2135) 2022-03-16 00:43:20 +01:00
Becir Basic
5c38c3b770
Recover middleware should not log panic for aborted handler (#2134, fixes #2133)
Co-authored-by: Becir Basic <bb@neotel.at>
2022-03-16 00:29:42 +01:00
Martti T
4a1ccdfdc5
JWT, KeyAuth, CSRF multivalue extractors (#2060)
* CSRF, JWT, KeyAuth middleware support for multivalue value extractors
* Add flag to JWT and KeyAuth middleware to allow continuing execution `next(c)` when error handler decides to swallow the error (returns nil).
2022-01-24 22:03:45 +02:00
ant1k9
7c41b93f0c
Add LogErrorFunc to recover middleware (#2072)
LogErrorFunc provides more general interface to handle errors in the recover middleware.
2022-01-24 11:23:41 +01:00
toimtoimtoim
6f6befe555 improve docs 2022-01-03 21:04:17 +02:00
toimtoimtoim
5b26a5257b Allow header support in Router, MethodNotFoundHandler (405) and CORS middleware 2022-01-03 21:04:17 +02:00
Rashad Ansari
4fffee2ec8 Add custom jwt extractor to jwt config 2021-12-20 21:41:59 +02:00
Nao Yonashiro
7bde9aea06
Fixed a problem that returned wrong content-encoding when the gzip compressed content was empty (#1921)
Fixed a problem that returned wrong content-encoding when the gzip compressed content was empty
2021-12-15 10:15:13 +02:00
Guilherme Cardoso
c32fafad68 Add support for configurable target header for the request_id middleware 2021-12-07 21:34:16 +02:00
David Desmarais-Michaud
b437ee3879
stream decompression instead of buffering (#2018)
* stream decompression instead of buffering
* simple body replace with gzip reader with deferred close
* defer resource closes
* simply gzip.Reader pool
2021-12-03 11:03:42 +01:00
Luka Jajanidze
902c553552 Added comments for RateLimiterMemoryStoreConfig and RateLimiterMemoryStore 2021-11-21 18:22:14 +02:00
Luka Jajanidze
3f099663f1 removed unnecessary comments 2021-11-21 18:22:14 +02:00
Luka Jajanidze
bd29ef9e46 added references to Limiter docs for 0-1 behaviour 2021-11-21 18:22:14 +02:00
Kaan Karakaya
d604704563 Fix rate limiter example
time.Minutes is doesn't exist
2021-10-15 21:08:11 +03:00
Martti T
a2e6ca7ed6
Add start time to request logger middleware values (#1991) 2021-09-23 23:17:09 +03:00
Martti T
1e7e67cddb
Added request logger middleware which helps to use custom logger library for logging requests (#1980)
Added request logger middleware which helps to use custom logger library for logging requests.
2021-09-14 20:57:47 +03:00