使用 define-easy-handler returns 404 定义的端点

Endpoint defined with define-easy-handler returns 404

我在helloworld.asd中定义了一个简单的系统:

(asdf:defsystem #:helloworld
  :description "helloworld"
  :author "Duncan Bayne <duncan@bayne.id.au>"
  :license "WTFNMF"
  :depends-on (#:hunchentoot)
  :serial t
  :components ((:file "package")
               (:file "helloworld")))

...package.lisp中的包定义:

(defpackage #:helloworld
  (:use #:cl #:hunchentoot))

...以及 helloworld.lisp 中相应的 hello world 网络服务器:

(in-package #:helloworld)

(defvar *acceptor* (make-instance 'acceptor :port 4242))

(start *acceptor*)

(define-easy-handler (greet :uri "/hello") ()
  "<html><body><h1>Hello World!</h1></body></html>")

在 SLIME REPL 中,我使用以下命令启动 Web 服务器:

CL-USER> (load "/usr/home/duncan/code/helloworld/helloworld.asd")
CL-USER> (ql:quickload "helloworld")

如果我导航到 http://localhost:4242/hello,我希望看到我的 hello world HTML。相反,我收到 404 错误,并且日志显示:

127.0.0.1 - [2017-08-10 08:18:19] "GET /hello HTTP/1.1" 404 341 "-" "Mozilla/5.0 (X11; FreeBSD amd64; rv:54.0) Gecko/20100101 Firefox/54.0"

我怀疑我在这里遗漏了一些相当明显的东西;任何提示/文档指针将不胜感激。系统详细信息是:

Clozure Common Lisp Version 1.11 (FreebsdX8664)
FreeBSD 11.1-RELEASE amd64
Hunchentoot 1.2.37
Mozilla Firefox 54.0.1
SLIME 20170804.1113

您正在创建 ACCEPTOR 的实例而不是 EASY-ACCEPTOR(或子类)。 easy handler 已注册,但您的接受者不会使用它。这应该有效,例如:

(defvar *acceptor* (make-instance 'easy-acceptor :port 4242))
(start *acceptor*)
(define-easy-handler (test :uri "/test") () "Pass")