mirror of
https://github.com/vale981/lack
synced 2025-03-06 01:41:39 -05:00
36 lines
1 KiB
Common Lisp
36 lines
1 KiB
Common Lisp
(in-package :cl-user)
|
|
(defpackage t.lack.middleware.static
|
|
(:use :cl
|
|
:prove
|
|
:lack
|
|
:lack.test))
|
|
(in-package :t.lack.middleware.static)
|
|
|
|
(plan nil)
|
|
|
|
#+thread-support
|
|
(subtest-app "static middleware"
|
|
(builder
|
|
(:static :path "/public/"
|
|
:root (asdf:system-relative-pathname :lack #P"data/"))
|
|
(lambda (env)
|
|
(declare (ignore env))
|
|
`(200 (:content-type "text/plain") ("Happy Valentine!"))))
|
|
(multiple-value-bind (body status headers)
|
|
(dex:get (localhost "/public/jellyfish.jpg"))
|
|
(is status 200)
|
|
(is (gethash "content-type" headers) "image/jpeg")
|
|
(is (length body) 139616))
|
|
(multiple-value-bind (body status)
|
|
(dex:get (localhost "/public/hoge.png"))
|
|
(is status 404)
|
|
(is body "Not Found"))
|
|
(multiple-value-bind (body status headers)
|
|
(dex:get (localhost "/"))
|
|
(is status 200)
|
|
(ok (string= (gethash "content-type" headers) "text/plain" :end1 10))
|
|
(is body "Happy Valentine!")))
|
|
#-thread-support
|
|
(skip 1 "because your lisp doesn't support threads")
|
|
|
|
(finalize)
|