26 lines
902 B
Common Lisp
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)))
|