(define SERVER-ROOT "public_gemini")
(define SERVER-HOST "thelambdalab.xyz")
+(define file-types
+ '(("gmi" "text/gemini; charset=utf8")
+ ("txt" "text/plain; charset=utf8")))
+
(define (process-request request-line)
(condition-case
(let ((uri (uri-normalize-path-segments (absolute-uri request-line))))
(print "50 " reason "\r"))
(define (document-available? uri)
- (let ((path (apply make-pathname (cons SERVER-ROOT (cdr (uri-path uri))))))
- (file-exists? path)))
-
+ (print (document-path uri))
+ (file-exists? (document-path uri)))
+(define (document-path uri)
+ (let* ((crumbs (reverse (cons SERVER-ROOT (cdr (uri-path uri)))))
+ (path (make-pathname (reverse (cdr crumbs)) (car crumbs))))
+ (if (directory-exists? path)
+ (make-pathname path "index.gmi")
+ path)))
+
(define (serve-document uri)
- (print "20 Surprise!\r"))
+ (let ((path (document-path uri)))
+ (print "20 Surprise!\r")))
-(process-request "gemini://thelambdalab.xyz/../index")
+(process-request "gemini://thelambdalab.xyz//")