Skip to content

Instantly share code, notes, and snippets.

@jodosha
Last active January 4, 2016 19:09
Show Gist options
  • Save jodosha/8665228 to your computer and use it in GitHub Desktop.
Save jodosha/8665228 to your computer and use it in GitHub Desktop.
Building Sinatra with Lotus
Gem::Specification.new do |s|
s.name = 'lotus-sinatra'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Luca Guidi'
s.email = '[email protected]'
s.summary = 'Building Sinatra with Lotus'
s.description = 'A step by step guide about how use Lotus to build Sinatra'
s.homepage = 'http://bit.ly/1e4e58T'
s.license = 'MIT'
s.files = ['lotus-sinatra.rb']
s.require_path = '.'
s.add_dependency 'lotus-router', '~> 0.1.0'
end
require 'rubygems'
require 'lotus/router'
class Endpoint < Lotus::Routing::Endpoint
def call(env)
[200, {}, [super(params(env))]]
end
private
def params(env)
env.fetch('router.params')
end
end
resolver = Lotus::Routing::EndpointResolver.new(endpoint: Endpoint)
Application = Rack::Builder.new do
run Lotus::Router.new(resolver: resolver)
end.to_app
def method_missing(m, *args, &blk)
if Application.respond_to?(m)
Application.send m, *args, &blk
else
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment