Class: Etcweb::App
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Etcweb::App
- Defined in:
- lib/etcweb/app.rb
Class Method Summary collapse
Class Method Details
.initialize_context(config) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/etcweb/app.rb', line 38 def self.initialize_context(config) {}.tap do |ctx| ctx[:etcd] = initialize_etcd(config[:etcd] || {}) ctx[:config] = config end end |
.initialize_etcd(config) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/etcweb/app.rb', line 28 def self.initialize_etcd(config) # etcd v0.2.4 (latest as of Mar 31, 2015) doesn't set TLS parameters in constructor # https://github.com/ranjib/etcd-ruby/commit/bf2c7e6dee8b2c07f85cca8541d16dcbef67cc1a Etcd.client(config).tap do |etcd| etcd.config.ca_file = config[:ca_file] etcd.config.ssl_cert = config[:ssl_cert] etcd.config.ssl_key = config[:ssl_key] end end |
.rack(config = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/etcweb/app.rb', line 45 def self.rack(config={}) klass = self context = initialize_context(config) app = lambda { |env| env['etcweb'] = context klass.call(env) } Rack::Builder.app do map '/assets' do run klass.sprockets end map '/' do run app end end end |