diff --git a/backend/brminv.scm b/backend/brminv.scm index 2a3f191..51ee152 100644 --- a/backend/brminv.scm +++ b/backend/brminv.scm @@ -3,11 +3,15 @@ texts spiffy openssl - (chicken tcp)) + (chicken tcp) + intarweb + uri-common) (define -port- (make-parameter #f)) (define -certificate- (make-parameter #f)) (define -key- (make-parameter #f)) +(define -user- (make-parameter #f)) +(define -group- (make-parameter #f)) (command-line print-help @@ -48,3 +52,22 @@ (ssl-listen port) (tcp-listen port))) +(when (and (-user-) (-group-)) + (switch-user/group (-user-) (-group-))) + +(handle-not-found + (lambda (path) + (define path-lst (uri-path (request-uri (current-request)))) + (print (car path-lst)) + (define body + (cond ((equal? (car path-lst) '/) + (print "index") + (frontend-lookup "index.html" "index not found")) + (else + "error"))) + (send-response #:body body))) + +(accept-loop listener + (if ssl? + ssl-accept + tcp-accept))