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