2

我正在学习 common lisp 并尝试使用 hunchentoot 开发网络应用程序。

使用下面的代码,我无法在浏览器上查看复古游戏功能定义中定义的页面。我希望它是由这个函数生成的。

我写地址为:

http://localhost:8080/retro-games.htm.

浏览器上显示的是Resource /retro-games.htm not found我可以显示的默认页面上的消息和 lisp 徽标。我可以显示hunchentoot的默认页面。

(ql:quickload "hunchentoot")
(ql:quickload "cl-who")

(defpackage :retro-games
  (:use :cl :cl-who :hunchentoot))
(in-package :retro-games);i evaluate this from toplevel otherwise it does not change to this package.

(start (make-instance 'hunchentoot:acceptor :port 8080))

(defun retro-games ()
    (with-html-output (*standard-output* nil :prologue t)
      (:html (:body "Not much there"))
      (values)))

(push (create-prefix-dispatcher "/retro-games.htm" 'retro-games) *dispatch-table*)

一开始的两次加载都是成功的。

我错过了什么?

4

2 回答 2

2

Hunchentoot的 API 自编写以来发生了一些变化。acceptor该文章假定的行为现在可以在 中找到easy-acceptorAcceptor现在是一个更通用的类,如果您愿意,可以将其用于您自己的调度机制。

所以,而不是(make-instance 'hunchentoot:acceptor #|...|#),使用(make-instance 'hunchentoot:easy-acceptor #|...|#),它应该工作。

于 2013-07-23T12:36:28.190 回答
1

的请求调度方法的默认实现acceptor,生成 HTTP Not Found 错误。因此,您需要对类进行子acceptor类化并在子类中重新定义acceptor-dispatch-request方法以使其实际调度请求。例如参见文档easy-acceptor有效,因为它定义acceptor-dispatch-request用于*dispatch-table*路由。

于 2013-07-23T12:28:57.827 回答