Created
July 4, 2018 17:03
-
-
Save bernardo-amorim/3cbcff63f1ca6fd97113873a29749117 to your computer and use it in GitHub Desktop.
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 'sinatra/base' | |
class ApplicationController < Sinatra::Base | |
def self.inherited sublass | |
super | |
Router.use(sublass) | |
end | |
def self.validated_get(route, &block) | |
get(route) do | |
block.call | |
end | |
end | |
end | |
class FooController < ApplicationController | |
def print_request | |
puts request | |
end | |
validated_get('/foo') do | |
print_request | |
"hi\n" | |
end | |
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 'json' | |
require './app' | |
require 'sinatra/base' | |
CONTROLLERS_PATH='./' | |
Router = Sinatra.new | |
class Sinatra::Request | |
def json | |
@json ||= (JSON.parse(self.body.read) rescue nil) | |
@json | |
end | |
end | |
#require "#{CONTROLLERS_PATH}/application_controller" | |
#Dir.glob('./lib/kuadro/models/*.rb').each { |file| require file} | |
#Dir.glob('./lib/kuadro/controllers/*.rb').each { |file| require file} | |
Router.run! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment