From: mike castleman Date: Sat, 9 Jan 2010 23:50:54 +0000 (-0500) Subject: some silly changes to msva-ruby X-Git-Tag: msva-perl/0.1~34 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=3e0579e86a651e786f02944872442ab3990c0e0b;p=monkeysphere-validation-agent.git some silly changes to msva-ruby --- diff --git a/msva.rb b/msva.rb index ca4be59..dd3c165 100644 --- a/msva.rb +++ b/msva.rb @@ -6,10 +6,20 @@ require 'json' require 'openssl' require 'sinatra' +configure do + git_dir = File.join(File.dirname(__FILE__), ".git") + if File.directory?(git_dir) + head = File.read("#{git_dir}/HEAD").strip.split[-1] + @@git_rev = File.read(File.join(git_dir, head)) + end +end + get '/' do - content_type 'text/plain; charset=us-ascii' + content_type "application/json" - "Hello from your friendly MSVA." + result = { :available => true, :protoversion => 1, :server => "MSVA-Ruby 0.00001" } + result[:git_revision] = @@git_rev if @@git_rev + result.to_json end post '/reviewcert' do @@ -18,7 +28,7 @@ post '/reviewcert' do begin params = JSON.parse(request.body.string) rescue JSON::ParserError - halt({ :valid => false, :message => "couldn't parse JSON query"}) + halt({ :valid => false, :message => "couldn't parse JSON query"}.to_json) end unless (params["pkc"] && params["pkc"]["type"] == "x509der") @@ -31,11 +41,12 @@ post '/reviewcert' do { :valid => false, :message => "Just testing!!" }.to_json end -get '/noop' do - { :available => true, :protoversion => 1, :server => "MSVA-Ruby 0.00001" }.to_json -end +# TODO: fill in if we need to do so +# post '/extracerts' do +# end + +not_found do + content_type "application/json" -post '/extracerts' do - # TODO: fill in if we need to do so - not_found + { :status => 404, :message => "not found" }.to_json end