How mix in routes in Sinatra for a better structure?

You could do this: module OtherRoutes def self. Included( app ) app. Get "/route1" do ... end end end class Server Note that with this you can't later monkey-patch OtherRoutes and have the changes reflected in Server; this is just a one-time convenience for defining the routes.

Well you can also use the map method to map routes to your sinatra apps map "/" do run Rack::Directory. New(". /public") end map '/posts' do run PostsApp.

New end map '/comments' do run CommentsApp. New end map '/users' do run UserssApp. New end.

1 A note of warning: the limitation of this approach is that map only accepts raw strings (no regexp allowed). – pithyless Apr 22 at 14:23.

You don't do include with Sinatra. You use extensions together with register. I.e.

Build your module in a separate file: require 'sinatra/base' module Sinatra module OtherRoutes def self. Registered(app) app. Get "/route1" do ... end end end register OtherRoutes # for non modular apps, just include this file and it will register end And then register: class Server Hope it helps others.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions