Rewriting #184

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

I've implemented URL rewriting. There's more info in README.rdoc, but basically it works like this:

rewrite '/this_page' => '/that_page'

rewrite '/foo/:x' do; "/bar/#{params[:x]}"; end

cactus commented Feb 13, 2011

Wouldn't url rewriting be a better fit for a rack middleware than in sinatra?

There's plenty of things that could be a better fit for middleware in Sinatra at the moment. I believe that the rewriting performed by this patch fits better with Sinatra's DSL philosophy. Setting up middleware for something like URL rewriting is just making things more complicated than they need to be.

Owner

rkh commented Feb 13, 2011

I'm with cactus on this one. Also, it's not much shorter than before { request.path_info = "/that_page" if request.path_info == "/thin_page" }, though I wouldn't really mind if this makes it into Sinatra. Maybe try to reach Blake, Simon and/or Ryan for feedback. Also, in most cases one probably wants a redirect rather than a rewrite, maybe a DSL for quick redirects would be better. Still, this should be done in a middleware. What we could do is offer a DSL for setting up such a middleware (as we do for sessions, the error page and others).

Owner

rkh commented Feb 19, 2011

I guess this is just too much sugar. Maybe create an extension?

@zzak zzak added a commit to zzak/sinatra that referenced this pull request Jul 22, 2016

@zzak zzak Merge pull request #184 from mono0x/issue_183
Use Mutex#synchronize instead of Thread.exclusive to prevent deprecation warning
c25e37b

@zzak zzak added a commit to zzak/sinatra that referenced this pull request Jul 22, 2016

@zzak zzak Merge pull request #184 from mono0x/issue_183
Use Mutex#synchronize instead of Thread.exclusive to prevent deprecation warning
c6a9048

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment