You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow inserting middleware at arbitrary points in the middleware stack
Changes include:
* Include the operation when stacking a new middleware
The operation gets stored before the rest of the middleware data
(class, args and block), and we use it later to determine the
order in which the middleware stack will be built.
Currently support `insert_after` and `insert_before`, plus `use`
that does the same as before.
* Implement a new `Grape::Middleware::Stack` class
This class contains the functionality to build the middleware stack
taking the different operations into account (`use`, `insert_before`
and `insert_after`). It's mostly based on `ActionDispatch::MiddlewareStack`
with some simplifications.
* Build middleware stack for endpoint using `Grape::Middleware::Stack`
Keep the same order for default middleware stack with `use` and use the
new class's `build` method to determine the real order of the final
stack.
* Fix small typo in `Grape::Util::StackableValues` (replace `froozen_values`
by `frozen_values`).
* Update `CHANGELOG` with the PR number.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
6
6
#### Features
7
7
8
+
*[#1390](https://github.com/ruby-grape/grape/pull/1390): Allow inserting middleware at arbitrary points in the middleware stack - [@Rosa](https://github.com/Rosa).
8
9
*[#1366](https://github.com/ruby-grape/grape/pull/1366): Store `message_key` on `Grape::Exceptions::Validation` - [@mkou](https://github.com/mkou).
You can add your custom middleware with `use`, that push the middleware onto the stack, and you can also control where the middleware is inserted using `insert`, `insert_before` and `insert_after`.
0 commit comments