Skip to content

Instantly share code, notes, and snippets.

@joekarma
Created October 27, 2012 19:30
Show Gist options
  • Select an option

  • Save joekarma/3965781 to your computer and use it in GitHub Desktop.

Select an option

Save joekarma/3965781 to your computer and use it in GitHub Desktop.
(defpackage :hunchentoot-demo
(:use :cl :alexandria))
(in-package :hunchentoot-demo)
(defclass acceptor (hunchentoot:acceptor) ())
(defvar *acceptor* (make-instance 'acceptor))
(defvar *routes* nil)
(defun four-oh-four () "404")
(defun choose-route (request)
(let ((route (assoc (hunchentoot:request-uri request)
*routes*
:test #'string=)))
(if route
(funcall (symbol-function (cdr route)) request)
(funcall #'four-oh-four request))))
(defmethod hunchentoot:handle-request ((acceptor acceptor) request)
(choose-route request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment