1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | (in-package #:gitbrn) (defparameter *server* (make-instance 'easy-routes:easy-routes-acceptor :port 3001 :address "0.0.0.0")) (defvar *current-user* nil) (defmethod hunchentoot:handle-request ((hunchentoot:acceptor (eql *server*)) request) (let* ((*current-user* (get-current-user request))) (progn (format t "~a" *current-user*) (call-next-method)))) (defun get-current-user (request) (let ((session (hunchentoot:cookie-in "session" request))) (sqlite:execute-single *db* "select u.username from users u join sessions s on u.id = s.user_id where s.token = ?" session))) (push (hunchentoot:create-folder-dispatcher-and-handler "/static/assets/" "/home/mcksp/proj/gitbrn/assets/") hunchentoot:*dispatch-table*) (defun start () (hunchentoot:start *server*)) (defun stop () (hunchentoot:stop *server*)) (defun main () (start) (sleep #xffffffff)) |