cl-chat-web/live-chat-routes.lisp
Bubblegumdrop ec06b36df0 Move the chat box into the navbar.
Why? I dunno. I think it looks cool.
2024-10-14 05:34:03 -04:00

26 lines
925 B
Common Lisp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(in-package #:live-chat-routes)
;; Define a app for routing
(defparameter *app* (make-instance 'ningle:app))
;; Route to render the chat UI
(setf (ningle:route *app* "/" :method :GET)
#'(lambda (params)
(declare (ignore params))
(live-chat-ui:render-chat-ui))
;; Route for chat messages
(ningle:route *app* "/chat-messages" :method :GET)
#'(lambda (params)
(declare (ignore params))
(live-chat-ui:render-chat-messages))
;; Route for posting messages
(ningle:route *app* "/post-message" :method :POST)
#'(lambda (params)
(let ((message (cdr (assoc "message" params :test 'equal))))
(when (and message (not (string= message "")))
(live-chat-ws:handle-post-message message)))
(live-chat-ui:render-chat-messages)))