summaryrefslogtreecommitdiff
path: root/lib/nickserver/request.rb
blob: 0d6dab6a1d1e1422108dc7f4656d1f845deebe41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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