Skip to content

Commit 1762e86

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

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
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:** 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)