开发者

Custom Subdomains in Sinatra app

I want my Sinatra app to allow users to create an account and access it via a subdomain (i.e. your-account.myapp.com).

开发者_JAVA技巧

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!


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜