Sinatra 应用程序中的自定义子域

发布于 2024-09-08 18:06:57 字数 311 浏览 1 评论 0原文

我希望我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌梦深 2024-09-15 18:06:57

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文