Switch web framework from Cuba to Roda #260
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Roda is a fork of Cuba. Here are the advantages I see to this change:
by default, routes in Cuba are not terminal. So the following
requests are currently handled the same by Tabula:
POST /upload
POST /upload/with/additional/stuff
Basically, you can stick whatever you want at the end of a path, and
Cuba will just ignore it. Roda has built in support for terminal
routes, so adding stuff at the end of the path will result in a
404, like practically all websites.
it so you don't have to set the Content-Type to application/json and
call .to_json manually. You just have the route block return an array
or hash, and Roda will automatically convert it to json for you.
While I was converting the app from Cuba to Roda, I noticed there were
some parts that could derive more benefit from the routing tree. One
example is TabulaDebug, where I moved a some duplicate code in every
route up to the enclosing branch, so the behavior is shared by all of
the routes under the branch.
Some things get a little more verbose with the switch, such as the
second argument to Roda#view is a general options hash instead of
specific to local variables. In general that could be made simpler by
passing data to the views implicitly using instance variables instead
of local variables.
Some other changes:
require 'tilt/erb' explicitly. This avoids some warnings printed
by tilt, which should be the case for both Roda and Cuba.
require tabula_debug and tabula_job_progress outside of the
routing tree, so they aren't required on every request that uses them.
Disclaimer: I'm the author of Roda.