diff --git a/lib/sharp-coin/interface/web.rb b/lib/sharp-coin/interface/web.rb index b5f5017..2e3ff91 100644 --- a/lib/sharp-coin/interface/web.rb +++ b/lib/sharp-coin/interface/web.rb @@ -13,17 +13,42 @@ module SharpCoin # # @author Nick Thomas class WebReal < Sinatra::Base + + # Proxy class to get Rack::CommonLogger lines into SharpCoin::Logging + # @author Nick Thomas + class LogProxy + include Logging + + def write(data) # Rack::CommonLogger uses this + log(:info, data) + end + + end set :environment, :production disable :sessions, :logging, :run, :dump_errors, :raise_errors, :lock enable :method_override, :static, :show_exceptions set :root, File.join(File.dirname(__FILE__), 'web') + + # Index page + get '/' do + [200, "Index"] + end + + # Put a new user into the database + get '/register' do + [200, "Register URL"] + end end Web = Rack::Builder.new do - map("/api/rpc/") { run JsonRPC } - map("/api/rest/") { run REST } - map("/") { run WebReal } + use Rack::CommonLogger, WebReal::LogProxy.new + map("/api") do + map("/rpc") { run JsonRPC } + map("/rest/") { run REST } + end + + map("/") { run WebReal } end end