Skip to content

Instantly share code, notes, and snippets.

@bernardo-amorim
Created July 4, 2018 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernardo-amorim/3cbcff63f1ca6fd97113873a29749117 to your computer and use it in GitHub Desktop.
Save bernardo-amorim/3cbcff63f1ca6fd97113873a29749117 to your computer and use it in GitHub Desktop.
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
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