Re: Module application server with Sinatra

28 views
Skip to first unread message

Carlos Eduardo L. Lopes

unread,
May 7, 2013, 10:40:19 AM5/7/13
to sina...@googlegroups.com
Hi Julien,

AFAIK, if you add the others apps to the middleware stack on the rack's land, they will be visible to rack but not to your main app.

What you can do is add the others apps as middleware inside the main app, here is an example:

class MyAppA < Sinatra::Base
  get '/a' do
    '<h1>Hello A</h1>'
  end
end

class MyAppB < Sinatra::Base
  get '/b' do
    '<h1>Hello B</h1>'
  end
end

class MainApp < Sinatra::Base
  use MyAppA
  use MyAppB

  get '/' do
    settings.middleware # => [[MyAppA, [], nil], [MyAppB, [], nil]]
    '<h1>Hello</h1>'
  end
end


Hope this can help you :)
--
Carlos Eduardo L. Lopes
Skype: carloslopespollares | Twitter: http://twitter.com/_carloslopes
GitHub: http://github.com/carloslopes



May 4, 2013 10:49 AM
Hi ML readers,

I would like to build a very simple application server using Sinatra.

To do so, the idea is to use the Rack config file to "register" applications.

Example:

use MyApp1
use MyApp2
...
run Middleware

However I am facing a weird problem: how can I retrieve the list of application from the top-level middleware (i.e. Middleware class/instance).

I need that to create links to applications from the main page of the application server website. I wondered to something like

middleware.get_apps which returns the list of application as a Hash.

Thanks for helping...

Julien.
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages