From 02c1d06dd19dddf1eec7ed960921f37f5b629194 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Wed, 26 Feb 2020 14:45:40 +0100 Subject: [PATCH] Primitive WIP UI added, useful mostly for debug. --- src/main.cr | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.cr b/src/main.cr index 9497b29..6b0ce22 100644 --- a/src/main.cr +++ b/src/main.cr @@ -1,6 +1,7 @@ require "uuid" require "option_parser" require "openssl" +require "colorize" require "jwt" require "ipc" @@ -324,6 +325,14 @@ class AuthD::Service @users_per_uid.get? token_payload.uid.to_s end + def info(message) + STDOUT << ":: ".colorize(:green) << message.colorize(:white) << "\n" + end + + def error(message) + STDOUT << "!! ".colorize(:red) << message.colorize(:red) << "\n" + end + def run ## # Provides a JWT-based authentication scheme for service-specific users. @@ -339,11 +348,16 @@ class AuthD::Service begin request = Request.from_ipc event.message + info "<< #{request.class.name.sub /^Request::/, ""}" + response = handle_request request, event.connection + info ">> #{response.class.name.sub /^Response::/, ""}" + event.connection.send response rescue e - STDERR.puts "error: #{e.message}" + error "!! #{e.message}" + event.connection.send Response::Error.new e.message end end end