Sinatra 应用程序中的自定义子域
我希望我的 Sinatra 应用程序允许用户创建帐户并通过子域(即 your-account.myapp.com)访问它。
我发现这个可以提取子域(http://gist.github.com/55784#file_subdomains.rb )但我很难实现它。
有什么想法吗?
我有一个帐户模型(数据映射器),其中有一个名为帐户名称的字段,该字段应该是子域。
谢谢!
I want my Sinatra app to allow users to create an account and access it via a subdomain (i.e. your-account.myapp.com).
I found this to extract subdomains (http://gist.github.com/55784#file_subdomains.rb) but I'm having a hard time implementing it.
Any ideas?
I have an Account model (datamapper) with a field called account name, which should be the subdomain.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sinara 使用 Rack 与网络服务器交互。
您可以在所有提取子域的请求之前放置一个 Rack 中间件,将其存储在本地变量中,并在需要加载该用户的任何地方使用它。
我找到了 2 个可以帮助您的资源:
https://github.com/fnando/sinatra-subdomain
和
http://tannerburson.com/2009/01/extracting-subdomains-in-sinatra.html
问候!
Sinara uses Rack to interact with the webserver.
You could put a Rack middleware before all requests to extract the subdomain, store it on a local variable and use it wherever you need load that user.
I've found 2 resources that could help you:
https://github.com/fnando/sinatra-subdomain
and
http://tannerburson.com/2009/01/extracting-subdomains-in-sinatra.html
Regards!