Skip to content

Commit 17c7190

Browse files
committed
updating README to fix 404 error issue mounting using Cascade
1 parent 84d68bd commit 17c7190

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#### Fixes
88

99
* Your contribution here.
10+
* [#2089](https://github.com/ruby-grape/grape/pull/2089): Specify order of mounting Grape with Rack::Cascade in README - [@jonmchan](https://github.com/jonmchan).
11+
1012

1113
### 1.4.0 (2020/07/10)
1214

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,12 @@ class Web < Sinatra::Base
350350
end
351351

352352
use Rack::Session::Cookie
353-
run Rack::Cascade.new [API, Web]
353+
run Rack::Cascade.new [Web, API]
354354
```
355355

356+
Note that order of loading apps using `Rack::Cascade` matters. The grape application must be last if you want to raise custom 404 errors from grape (such as `error!('Not Found',404)`). If the grape application is not last and returns 404 or 405 response, [cascade utilizes that as a signal to try the next app](https://www.rubydoc.info/gems/rack/Rack/Cascade). This may lead to undesirable behavior showing the [wrong 404 page from the wrong app](https://github.com/ruby-grape/grape/issues/1515).
357+
358+
356359
### Rails
357360

358361
Place API files into `app/api`. Rails expects a subdirectory that matches the name of the Ruby module and a file name that matches the name of the class. In our example, the file name location and directory for `Twitter::API` should be `app/api/twitter/api.rb`.

0 commit comments

Comments
 (0)