Class: HttpLoader::Server

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/http_loader/server.rb

Overview

Server provides a lightweight, natively asynchronous HTTP/HTTPS mock endpoint

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



22
23
24
25
26
27
28
29
# File 'lib/http_loader/server.rb', line 22

def initialize
  @app = T.let(
    proc do |_env|
      [200, { 'Content-Type' => 'text/plain', 'Content-Length' => '2' }, ['OK']]
    end,
    T.proc.params(arg0: T::Hash[String, Object]).returns(T::Array[T.any(Integer, T::Hash[String, String], Object)])
  )
end

Instance Method Details

#start(use_https: false, port: 8080) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/http_loader/server.rb', line 32

def start(use_https: false, port: 8080)
  if use_https
    start_secure(port)
  else
    start_plaintext(port)
  end
end