fukamachi / ningle

Super micro framework for Common Lisp
http://8arrow.org/ningle/
273 stars 25 forks source link

Clackup with ningle throws error #35

Closed rajasegar closed 3 years ago

rajasegar commented 3 years ago

app.lisp

(ql:quickload '(:ningle))
(defvar *app* (make-instance 'ningle:app))

(setf (ningle:route *app* "/") "<h1>Welcome to ningle!</h1>")

Starting the server with:

clackup app.lisp

throws this error:

Backtrace for: #<SB-THREAD:THREAD "hunchentoot-worker-127.0.0.1:54316" RUNNING {1003ACF383}>
0: (SB-VM::CALL-SYMBOL)
1: ((LAMBDA (LACK.MIDDLEWARE.BACKTRACE::ENV) :IN "/Users/rajasegarchandran/.roswell/lisp/quicklisp/dists/quicklisp/software/lack-20210531-git/src/middleware/backtrace.lisp") (:REQUEST-METHOD :GET :SCRIPT-NAME "" :PATH-INFO "/" :SERVER-NAME "localhost" :SERVER-PORT 5000 :SERVER-PROTOCOL :HTTP/1.1 ...))
2: ((:METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST (CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<HUNCHENTOOT:REQUEST {10047CD463}>) [fast-method]
3: ((:METHOD HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<HUNCHENTOOT:REQUEST {10047CD463}>) [fast-method]
4: ((:METHOD HUNCHENTOOT:PROCESS-REQUEST (T)) #<HUNCHENTOOT:REQUEST {10047CD463}>) [fast-method]
5: (HUNCHENTOOT::DO-WITH-ACCEPTOR-REQUEST-COUNT-INCREMENTED #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<FUNCTION (LAMBDA NIL :IN HUNCHENTOOT:PROCESS-CONNECTION) {10045A5F3B}>)
6: ((:METHOD HUNCHENTOOT:PROCESS-CONNECTION (HUNCHENTOOT:ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {1003ACA9A3}>) [fast-method]
7: ((:METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (HUNCHENTOOT:ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {1003ACA9A3}>) [fast-method]
8: ((:METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {1003ACA9A3}>) [fast-method]
9: ((FLET HUNCHENTOOT::PROCESS-CONNECTION% :IN HUNCHENTOOT::HANDLE-INCOMING-CONNECTION%) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {1003ACA9A3}>)
10: ((LAMBDA NIL :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
11: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
12: ((FLET "WITHOUT-INTERRUPTS-BODY-11" :IN SB-THREAD::RUN))
13: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
14: ((FLET "WITHOUT-INTERRUPTS-BODY-4" :IN SB-THREAD::RUN))
15: (SB-THREAD::RUN)
16: ("foreign function: call_into_lisp")
17: ("foreign function: funcall1")
Above backtrace due to this condition:
The value "<h1>Welcome to ningle!</h1>" is not of type (OR FUNCTION SYMBOL)

Request:
    REQUEST-METHOD: :GET
    SCRIPT-NAME: ""
    PATH-INFO: "/"
    SERVER-NAME: "localhost"
    SERVER-PORT: 5000
    SERVER-PROTOCOL: :HTTP/1.1
    REQUEST-URI: "/"
    URL-SCHEME: "http"
    REMOTE-ADDR: "127.0.0.1"
    REMOTE-PORT: 54316
    QUERY-STRING: NIL
    RAW-BODY: #<FLEXI-STREAMS:FLEXI-IO-STREAM {1004AA7633}>
    CONTENT-LENGTH: NIL
    CONTENT-TYPE: NIL
    CLACK.STREAMING: T
    CLACK.IO: #<CLACK.HANDLER.HUNCHENTOOT::CLIENT {1004F1EF33}>
    HEADERS:
        host: "localhost:5000"
        connection: "keep-alive"
        sec-ch-ua: "\"Chromium\";v=\"92\", \" Not A;Brand\";v=\"99\", \"Google Chrome\";v=\"92\""  
        sec-ch-ua-mobile: "?0"
        upgrade-insecure-requests: "1"
        user-agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
        accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
        sec-fetch-site: "none"
        sec-fetch-mode: "navigate"
        sec-fetch-user: "?1"
        sec-fetch-dest: "document"
        accept-encoding: "gzip, deflate, br"
        accept-language: "en-GB,en-US;q=0.9,en;q=0.8,es-ES;q=0.7,es;q=0.6,fr;q=0.5"
        x-hl-auth-token: "rhbq078s7umafk8bvlqlmmb6kpqdv9egd2inb7jq"
The value
  "<h1>Welcome to ningle!</h1>"
is not of type

But the same works inside SLIME perfectly.

fukamachi commented 3 years ago

Add *app* at the last of app.lisp.

rajasegar commented 3 years ago

Thanks a lot @fukamachi , that worked!

(ql:quickload '(:ningle))
(defvar *app* (make-instance 'ningle:app))
(setf (ningle:route *app* "/") "<h1>Welcome to ningle!</h1>")
*app*