From 3e0579e86a651e786f02944872442ab3990c0e0b Mon Sep 17 00:00:00 2001 From: mike castleman Date: Sat, 9 Jan 2010 18:50:54 -0500 Subject: [PATCH] some silly changes to msva-ruby --- msva.rb | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) 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 -- 2.26.2