summaryrefslogtreecommitdiff
path: root/lib/nickserver
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nickserver')
-rw-r--r--lib/nickserver/couch/fetch_key.rb25
-rw-r--r--lib/nickserver/server.rb14
2 files changed, 11 insertions, 28 deletions
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