Sha256: 94a444bcfe8da97d1d5a9cd033a4c69e7e74525d4a6c071cf9958543b1045c7b
Contents?: true
Size: 870 Bytes
Versions: 2
Compression:
Stored size: 870 Bytes
Contents
require 'sinatra/base' require 'haml' require 'redcarpet' require 'json' require 'cgi' module CabbageDoc class Web < Sinatra::Base ROOT = File.expand_path("../../../web", __FILE__).freeze set :root, proc { dir = File.join(Configuration.instance.root, 'web') if Dir.exists?(dir) dir else ROOT end } set :public_folder, proc { "#{root}/public" } set :views, proc { "#{root}/views" } helpers WebHelper get '/' do haml :index end get '/:id' do response_by_id(params[:id]) end post '/' do response = Configuration.instance.request.call(post_request) if response.is_a?(Response) content_type :json response.to_json elsif post_request.valid? response_by_id(post_request.id) else halt 500 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cabbage_doc-0.0.4 | lib/cabbage_doc/web.rb |
cabbage_doc-0.0.3 | lib/cabbage_doc/web.rb |