Padrino applications are all automatically mountable into other Padrino projects. This means that a given Padrino project directory can easily mount multiple applications. This allows for better organization of complex applications, re-usable applications that can be applied (i.e admin, auth, blog) and even more flexibility.
You can think of mountable applications as a "full-featured" Merb slice or Rails engine. Instead of a separate construct, any application can simply be packaged and mounted into another project.
Padrino stores application mounting information by default within
config/apps.rb. This file is intended to keep all information regarding what
applications are mounted to which URI's. An
apps.rb file has the following
Padrino.mount("blog").to("/blog") Padrino.mount("website").to("/website") Padrino.mount("app").to("/")
This would mount three applications onto the Padrino project, one served from the '/blog' uri namespace one with '/website' uri namespace and the other served from the '/' uri namespace.
Advanced Mounting Support
In addition to the basic mounting capabilities afforded by Padrino for each application within a project, the Padrino Router also allows for more advanced mounting conditions.
Padrino::Router is an enhanced version of
Rack UrlMap which
extends the ability to mount applications to a specified path, or specify host
and subdomains to match to an application. For example, you could put the
following in your
# Adds support for matching an app to a host string or pattern Padrino.mount("Blog").to("/").host("blog.example.org") Padrino.mount("Admin").host("admin.example.org") Padrino.mount("WebSite").host(/.*\.?example.org/) Padrino.mount("Foo").to("/foo").host("bar.example.org")
This will configure each application to match to the given host pattern simplifying routing considerably.
last updated: 2019-01-14comments powered by Disqus