url = require "net.url" class Server new: (cq, hdlr) => @cq = cq @hdlr = hdlr listen: (srv) => @cq\wrap -> for conn in srv\clients! @cq\wrap -> with conn _, ip = \peername! request = \read "*l" u = url.parse request ctx = :ip host: u.host path: u.path query: u.query @hdlr\serve ctx, conn \close! { :Server }