Class: Requestkit::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/requestkit/server.rb,
lib/requestkit/server/render.rb,
lib/requestkit/server/request.rb

Defined Under Namespace

Classes: Render, Request

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Server

Returns a new instance of Server.



15
16
17
18
19
20
# File 'lib/requestkit/server.rb', line 15

def initialize(config)
  @config = config
  @port = config.port
  @db = Storage.new(config)
  @clients = []
end

Instance Method Details

#startObject



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

def start
  puts "📦 Requestkit starting on http://localhost:#{@port}"
  puts "Press Ctrl+C to stop"

  endpoint = Async::HTTP::Endpoint.parse("http://localhost:#{@port}")

  Async do
    Async::HTTP::Server.new(method(:route), endpoint).run
  end
end