summaryrefslogtreecommitdiff
path: root/lib/nickserver/request_handlers/fingerprint_handler.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-08-30 12:10:57 +0200
committerAzul <azul@riseup.net>2016-08-30 12:36:40 +0200
commitb22e23eb9f5a1cb3e37ab2a26b1091183574f4e4 (patch)
treeb3ca7f91dd78994c5d0164645922b3929b9177a3 /lib/nickserver/request_handlers/fingerprint_handler.rb
parent494e6f32daf0f6bf37321507b83848b4be087100 (diff)
refactor: make the RequestHandler classes callable
Whenever a RequestHandler class is called we instantiate it with the request. Then we call handle on the instance. This way we can access the request and its content via accessors rather than only in the handle method.
Diffstat (limited to 'lib/nickserver/request_handlers/fingerprint_handler.rb')
-rw-r--r--lib/nickserver/request_handlers/fingerprint_handler.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/nickserver/request_handlers/fingerprint_handler.rb b/lib/nickserver/request_handlers/fingerprint_handler.rb
index 3c04fcd..5b2dc7d 100644
--- a/lib/nickserver/request_handlers/fingerprint_handler.rb
+++ b/lib/nickserver/request_handlers/fingerprint_handler.rb
@@ -1,27 +1,30 @@
+require 'nickserver/request_handlers/base'
require 'nickserver/hkp/source'
require 'nickserver/error_response'
module Nickserver
module RequestHandlers
- class FingerprintHandler
+ class FingerprintHandler < Base
- def call(request)
- return unless request.fingerprint
- handle_request(request)
- end
-
- protected
-
- def handle_request(request)
- fingerprint = request.fingerprint
+ def handle
+ return unless fingerprint
if fingerprint.length == 40 && !fingerprint[/\H/]
- source = Nickserver::Hkp::Source.new
source.get_key_by_fingerprint(fingerprint)
else
ErrorResponse.new('Fingerprint invalid: ' + fingerprint)
end
end
+ protected
+
+ def fingerprint
+ request.fingerprint
+ end
+
+ def source
+ Nickserver::Hkp::Source.new
+ end
+
end
end
end