Log proxy for the web interface
This commit is contained in:
@@ -13,16 +13,41 @@ module SharpCoin
|
||||
#
|
||||
# @author Nick Thomas <nick@lupine.me.uk>
|
||||
class WebReal < Sinatra::Base
|
||||
|
||||
# Proxy class to get Rack::CommonLogger lines into SharpCoin::Logging
|
||||
# @author Nick Thomas <nick@lupine.me.uk>
|
||||
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 }
|
||||
use Rack::CommonLogger, WebReal::LogProxy.new
|
||||
map("/api") do
|
||||
map("/rpc") { run JsonRPC }
|
||||
map("/rest/") { run REST }
|
||||
end
|
||||
|
||||
map("/") { run WebReal }
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user