cl-chat-web/live-chat-routes.lisp
Bubblegumdrop 8d3e31ef56 Fully WebSocket Server.
We're now using clack, lack, ningle, and websocket-driver.

Quite a few more dependencies.
2024-10-12 19:53:34 -04:00

26 lines
902 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
(setf (ningle:route *app* "/chat-messages" :method :GET)
#'(lambda (params)
(declare (ignore params))
(live-chat-ui:render-chat-messages)))
;; Route for posting messages
(setf (ningle:route *app* "/post-message" :method :POST)
#'(lambda (params)
(let ((message (cdr (assoc "message" params :test 'equal))))
(when (and message (not (string= message "")))
(handle-post-message message)))
(live-chat-ui:render-chat-messages)))