Class: DNSUpdater::Web
- Inherits:
-
Object
- Object
- DNSUpdater::Web
- Defined in:
- lib/dnsupdater/web.rb
Overview
HTTP updater web server
Class Method Summary collapse
- .getServerConfig(webConfig, protocol, params) ⇒ Object
- .startServer(configFile, protocol, params) ⇒ Object
Instance Method Summary collapse
- #call(env) ⇒ Object
- #getConfig ⇒ Object
-
#initialize(configFile) ⇒ Web
constructor
A new instance of Web.
Constructor Details
Class Method Details
.getServerConfig(webConfig, protocol, params) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dnsupdater/web.rb', line 35 def self.getServerConfig(webConfig, protocol, params) webConfig.setTargetProtocol(:http, protocol) config = Hash[webConfig['HTTP'].map { |k, v| [k.to_sym, v] }] config[:Host] = Addressable::IDNA.to_ascii(params[:Server]) unless params[:Server].to_s.empty? config[:Port] = params[:Port] if params[:Port].to_i.positive? config[:environment] = 'production' config end |
.startServer(configFile, protocol, params) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/dnsupdater/web.rb', line 26 def self.startServer(configFile, protocol, params) web = new(configFile) config = getServerConfig(web.getConfig, protocol, params) Rack::Handler::Puma.run(web, config) rescue IOError, SocketError, SystemCallError => e raise Error, self.class.name + ': ' + e. end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 |
# File 'lib/dnsupdater/web.rb', line 20 def call(env) @HTTP.call(env) rescue RuntimeError => e @HTTP.class.formatResponse(500, e.) end |
#getConfig ⇒ Object
16 17 18 |
# File 'lib/dnsupdater/web.rb', line 16 def getConfig @Config end |