[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Serving files with guile web server
From: |
romel |
Subject: |
Re: Serving files with guile web server |
Date: |
Sat, 19 Mar 2011 18:23:33 -0400 (EDT) |
User-agent: |
SquirrelMail/1.4.13 |
Neil Jerram writes:
> Certainly, it looks good. Where does mime-type-ref come from, though?
>
Thanks, mime-type-ref comes from (glider mime-types) it's a little module
I wrote specifically for this purpose, see code below
(define-module (glider mime-types)
:export (mime-type-ref text-mime-type? mime-type-symbol))
(define *mime-types* (make-hash-table 31))
(hash-set! *mime-types* "css" '("text" . "css"))
(hash-set! *mime-types* "txt" '("text" . "plain"))
(hash-set! *mime-types* "png" '("image" . "png"))
(hash-set! *mime-types* "jpg" '("image" . "jpeg"))
(hash-set! *mime-types* "jpeg" '("image" . "jpeg"))
(hash-set! *mime-types* "gif" '("image" . "gif"))
(define (mime-type-ref file-name)
(let* ((dot-position (string-rindex file-name #\.))
(extension (and dot-position
(string-copy file-name (+ dot-position 1))))
(mime-type (and dot-position
(hash-ref *mime-types* extension))))
(if mime-type mime-type '("application" . "octet-stream"))))
(define (mime-type-symbol mime-type)
(string->symbol (string-append (car mime-type) "/" (cdr mime-type))))
(define (text-mime-type? mime-type)
(if (equal? (car mime-type) "text") #t #f))
> Perhaps that could be wrapped up as `static-file-response' (or a better
> name if you can think of one) and added to (web server).
It would be great to have static file serving available from (web server),
I think that static-file-response is a good name.
Thanks,
Romel Sandoval