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

时间:2017-08-09 22:27:08

标签: common-lisp hunchentoot

我在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

1 个答案:

答案 0 :(得分:3)

您正在创建test$income <- cut(test$income,b=25) levels <- c(-0.853,-0.586,-0.325,-0.0643,0.196,0.457,0.718,0.978,1.24,1.5,1.76,2.02,2.28,2.54,2.8,3.06,3.32,3.59,3.85,4.11,4.37,4.63,4.89,5.15,5.41,5.68) train$income <- cut(train$income,levels) 而不是ACCEPTOR(或子类)的实例。易处理程序已注册,但您的接受者不会使用它。这应该有用,例如:

EASY-ACCEPTOR