Handle static files

138 views
Skip to first unread message

Daimrod

unread,
May 2, 2012, 4:45:04 PM5/2/12
to Restas
Hi,

I've played a bit with Hunchentoot and I'm now trying Restas and I would
like to know what was the cleanest way to handle static files like
JavaScript files or images.

I've tried to define my own acceptor and to set the slot DOCUMENT-ROOT
but hunchentoot:handle-static-file, the method used when a route returns
a pathname, doesn't seem to use it.

So I've made a custom route like this

(define-route script-js ("*/:(name).js")
;; Route used to find JavaScript files
(declare (ignorable ||))
(make-pathname :name name
:type "js"
:directory '(:relative "script")))

And I use the following files hierarchy:

project/
| *.lisp
| *.asd
| README
| script/*.js
| images/*.(png|jpg|...)

Though I would like to put the directories script/ and images/ in a www/
without having to specify it in the route '(:relative "images") and not
'(:relative "www" "images").

project/
| *.lisp
| *.asd
| README
| www/
| script/*.js
| images/*.(png|jpg|...)

Or another solution would be to use a special variable *document-root*
for this module and use my own function to return the correct pathname.

What do you think?

Andrey Moskvitin

unread,
May 2, 2012, 4:58:38 PM5/2/12
to res...@googlegroups.com
Hi,

You can use my restas.directory-publisher
(https://github.com/archimag/restas-directory-publisher) module (see
example directory) or restas.file-publisher
(https://github.com/kevinlynx/restas.file-publisher). Both modules are
available via quicklisp.

2012/5/3 Daimrod <dai...@gmail.com>:

Daimrod

unread,
May 3, 2012, 4:22:11 AM5/3/12
to restas
On 2 mai, 22:58, Andrey Moskvitin <archi...@gmail.com> wrote:
> Hi,
>
> You can use my restas.directory-publisher
> (https://github.com/archimag/restas-directory-publisher) module (see
> example directory) or restas.file-publisher
> (https://github.com/kevinlynx/restas.file-publisher). Both modules are
> available via quicklisp.

Thanks, that was exactly what I was looking for.
Looks like I should have read the documentation more carefully!
Reply all
Reply to author
Forward
0 new messages