From: romel@lavabit.com
To: "Neil Jerram" <neil@ossau.uklinux.net>
Cc: guile-user@gnu.org
Subject: Re: Serving files with guile web server
Date: Sat, 19 Mar 2011 18:23:33 -0400 (EDT) [thread overview]
Message-ID: <1091.189.215.48.232.1300573413.squirrel@lavabit.com> (raw)
In-Reply-To: <87aagrrn43.fsf@ossau.uklinux.net>
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
next prev parent reply other threads:[~2011-03-19 22:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 23:33 Serving files with guile web server romel
2011-03-17 14:55 ` romel
2011-03-19 2:20 ` Neil Jerram
2011-03-19 16:47 ` romel
2011-03-19 18:17 ` Neil Jerram
2011-03-19 22:23 ` romel [this message]
2011-03-31 14:44 ` Andy Wingo
2011-03-22 8:51 ` Thien-Thi Nguyen
2011-03-31 14:23 ` Andy Wingo
2011-03-31 15:09 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1091.189.215.48.232.1300573413.squirrel@lavabit.com \
--to=romel@lavabit.com \
--cc=guile-user@gnu.org \
--cc=neil@ossau.uklinux.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).