Class: HTTPMe::Server
- Inherits:
-
Object
- Object
- HTTPMe::Server
- Defined in:
- lib/httpme/server.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #app ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
9 10 11 |
# File 'lib/httpme/server.rb', line 9 def initialize( = {}) = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/httpme/server.rb', line 7 def end |
Instance Method Details
#app ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/httpme/server.rb', line 23 def app path = [:path] || '.' auth = [:auth] zone = [:zone] || 'Restricted Area' Rack::Builder.new do if auth use Rack::Auth::Basic, zone do |username, password| auth.split(':') == [username, password] end end use Rack::Static, urls: ["/"], root: path, cascade: true, index: 'index.html' use IndexRedirector, root: path run Rack::Directory.new(path) end end |
#run ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/httpme/server.rb', line 13 def run Rack::Handler::Puma.run(app, **) do |server| # :nocov: - FIXME: Can we test this? [:INT, :TERM].each do |sig| trap(sig) { server.stop } end # :nocov: end end |