require "http/server" require "./config" require "./model" require "./handlers" module Guff class Server def self.run(model : Model) new(model).run end def initialize(@model : Model) # create server @server = HTTP::Server.new( @model.config["host"], @model.config["port"].to_i, get_handlers(@model) ) end def run puts "listening on %s:%s" % %w{host port}.map { |k| @model.config[k] } @server.listen end private def get_handlers(model : Model) : Array(HTTP::Handler) @handlers ||= Handlers.get(model) end end end