From 16d77cc03068b19791e704abfc2eb14f8cd141f0 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 27 Aug 2016 11:25:30 +0200 Subject: expose Request class from RequestHandler This way we can separate the EmailHandler and the FingerprintHandler as well. --- lib/nickserver/request.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/nickserver/request.rb (limited to 'lib/nickserver/request.rb') diff --git a/lib/nickserver/request.rb b/lib/nickserver/request.rb new file mode 100644 index 0000000..c21c280 --- /dev/null +++ b/lib/nickserver/request.rb @@ -0,0 +1,30 @@ +module Nickserver + class Request + def initialize(params, headers) + @params = params || {} + @headers = headers + end + + def email + param("address") + end + + def fingerprint + param("fingerprint") + end + + def domain + host_header = headers['Host'] || '' + domain_part = host_header.split(':')[0] || '' + domain_part.strip.sub(/^nicknym\./, '') + end + + protected + + def param(key) + params[key] && params[key].first + end + + attr_reader :params, :headers + end +end -- cgit v1.2.3