Last active
January 4, 2016 19:09
-
-
Save jodosha/8665228 to your computer and use it in GitHub Desktop.
Building Sinatra with Lotus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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