ruby - How can you set up scoped redirects for Sinatra apps -
i have series of sinatra applications set such each responsible 1 thing.
let's have 2 apps this:
class foo < sinatra::base '/' 'foo!' end end class zoo < sinatra::base '/' 'zoo!' end '/zoom' # things redirect '/' end end
now let's have config.ru such: require './application'
run rack::urlmap.new('/' => foo.new, '/zoo' => zoo.new)
the problem i'm running when seek redirect in zoom
action sent off index action of foo
instead of zoo
. there clean way such applications don't need know how routes set app?
you can utilize configurable redirects. see http://www.sinatrarb.com/2011/03/03/sinatra-1.2.0.html#configurable_redirects.
e.g.
class zoo < sinatra::base '/' 'zoo!' end '/zoom' # things redirect to('/') end end
or alternatively, mentioned in link above, skip to() phone call enabling prefixed redirects in zoo app:
class zoo < sinatra::base enable :prefixed_redirects ...
ruby sinatra rack
No comments:
Post a Comment