1 ;;; auto-mode-server.el --- files with fontification from the `auto-mode-alist'
4 (lexical-let ((docroot default-directory))
7 (with-slots (process headers) request
8 (let ((path (ws-in-directory-p
9 docroot (substring (cdr (assoc :GET headers)) 1))))
11 (if (file-directory-p path)
12 (ws-send-directory-list process
13 (expand-file-name path docroot) "^[^\.]")
14 ;; send htmlize version of file
15 (let ((mode (or (cdr (cl-assoc-if (lambda (re) (string-match re path))
18 (ws-response-header process 200
19 '("Content-type" . "text/html; charset=utf-8"))
20 (process-send-string process
22 (insert-file-contents-literally path)
24 (let ((html (htmlize-buffer)))
25 (prog1 (with-current-buffer html (buffer-string))
26 (kill-buffer html)))))))
27 (ws-send-404 process)))))