带有sinatra / padrino的别名URL [英] alias url with sinatra / padrino

查看:60
本文介绍了带有sinatra / padrino的别名URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做到了,而且有效

I've this and it works

  get :about, :map => '/about_us' do
    render :erb, "<%= 'foo' %>"
  end
  get '/:slug' do
    redirect "/about_us" # <--
  end

是否可以通过某种方式渲染而不是重定向?
或诸如render'posts / 1'之类的东西

Is possible to do in some way "render" instead of "redirect"? or something like render 'posts/1'

推荐答案

get :about, :map => '/about_us' do
  render :erb, "<%= 'foo' %>"
end

get '/:slug' do
  call env.merge('PATH_INFO' => '/about_us')
end

这篇关于带有sinatra / padrino的别名URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆