Module: Bormashino::Server
- Defined in:
- lib/bormashino/server.rb
Overview
pseudo rack server module
Class Method Summary collapse
- .mount(app_class) ⇒ Object
- .mounted? ⇒ Boolean
- .request(method, target, payload = '', referer = '') ⇒ Object
Class Method Details
.mount(app_class) ⇒ Object
11 12 13 |
# File 'lib/bormashino/server.rb', line 11 def self.mount(app_class) @app = app_class.new end |
.mounted? ⇒ Boolean
7 8 9 |
# File 'lib/bormashino/server.rb', line 7 def self.mounted? !@app.nil? end |
.request(method, target, payload = '', referer = '') ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bormashino/server.rb', line 15 def self.request(method, target, payload = '', referer = '') u = URI(target) @app.call({ 'HTTP_HOST' => 'example.com:0', 'REQUEST_METHOD' => method.upcase, 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', 'QUERY_STRING' => u.query, 'PATH_INFO' => u.path, 'HTTP_REFERER' => referer, 'rack.input' => StringIO.new(payload), 'rack.errors' => StringIO.new(''), }).to_json end |