summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nickserver.rb2
-rw-r--r--lib/nickserver/couch/fetch_key.rb25
-rw-r--r--lib/nickserver/server.rb14
3 files changed, 11 insertions, 30 deletions
diff --git a/lib/nickserver.rb b/lib/nickserver.rb
index eb7eddb..22d4b43 100644
--- a/lib/nickserver.rb
+++ b/lib/nickserver.rb
@@ -3,8 +3,6 @@ require "nickserver/version"
require "nickserver/config"
require "nickserver/email_address"
-require "nickserver/couch/fetch_key"
-
require "nickserver/hkp/fetch_key"
require "nickserver/hkp/fetch_key_info"
require "nickserver/hkp/parse_key_info"
diff --git a/lib/nickserver/couch/fetch_key.rb b/lib/nickserver/couch/fetch_key.rb
deleted file mode 100644
index 2013bca..0000000
--- a/lib/nickserver/couch/fetch_key.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'nickserver/couch_db/source'
-require 'nickserver/adapters/em_http'
-
-module Nickserver; module Couch
- class FetchKey
-
- def initialize(options={})
- @source = Nickserver::CouchDB::Source.new(adapter)
- end
-
- def get(uid, &block)
- source.query(uid, &block)
- end
-
- protected
-
- attr_reader :source
-
- def adapter
- @adapter ||= Nickserver::Adapters::EmHttp.new
- end
-
-
- end
-end; end
diff --git a/lib/nickserver/server.rb b/lib/nickserver/server.rb
index 9e1551b..b528e4b 100644
--- a/lib/nickserver/server.rb
+++ b/lib/nickserver/server.rb
@@ -4,6 +4,9 @@ silence_warnings do
require 'evma_httpserver'
end
require 'json'
+require 'nickserver/couch_db/source'
+require 'nickserver/adapters/em_http'
+
#
# This is the main HTTP server that clients connect to in order to fetch keys
@@ -93,8 +96,8 @@ module Nickserver
def get_key_from_uid(uid)
if local_address?(uid)
- @fetcher = Nickserver::Couch::FetchKey.new
- @fetcher.get(uid) do |response|
+ @source = Nickserver::CouchDB::Source.new(adapter)
+ @source.query(uid) do |response|
send_response(status: response.status, content: response.content)
end
else
@@ -135,8 +138,13 @@ module Nickserver
return uid_domain == host
end
end
- rescue
+ rescue # XXX what are we rescueing here?
return false
end
+
+ def adapter
+ @adapter ||= Nickserver::Adapters::EmHttp.new
+ end
+
end
end