Log proxy for the web interface
This commit is contained in:
@@ -13,17 +13,42 @@ module SharpCoin
|
|||||||
#
|
#
|
||||||
# @author Nick Thomas <nick@lupine.me.uk>
|
# @author Nick Thomas <nick@lupine.me.uk>
|
||||||
class WebReal < Sinatra::Base
|
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
|
set :environment, :production
|
||||||
disable :sessions, :logging, :run, :dump_errors, :raise_errors, :lock
|
disable :sessions, :logging, :run, :dump_errors, :raise_errors, :lock
|
||||||
enable :method_override, :static, :show_exceptions
|
enable :method_override, :static, :show_exceptions
|
||||||
|
|
||||||
set :root, File.join(File.dirname(__FILE__), 'web')
|
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
|
end
|
||||||
|
|
||||||
Web = Rack::Builder.new do
|
Web = Rack::Builder.new do
|
||||||
map("/api/rpc/") { run JsonRPC }
|
use Rack::CommonLogger, WebReal::LogProxy.new
|
||||||
map("/api/rest/") { run REST }
|
map("/api") do
|
||||||
map("/") { run WebReal }
|
map("/rpc") { run JsonRPC }
|
||||||
|
map("/rest/") { run REST }
|
||||||
|
end
|
||||||
|
|
||||||
|
map("/") { run WebReal }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user