Module: Bormashino::Server

Defined in:
lib/bormashino/server.rb

Class Method Summary collapse

Class Method Details

.mount(app_class) ⇒ Object



6
7
8
# File 'lib/bormashino/server.rb', line 6

def self.mount(app_class)
  @app = app_class.new
end

.request(method, target, payload = '', referer = '') ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bormashino/server.rb', line 10

def self.request(method, target, payload = '', referer = '')
  u = URI(target)

  @app.call({
              'HTTP_HOST' => 'example.com:0',
              'REQUEST_METHOD' => method,
              '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