Add get payload for path method

This commit is contained in:
TakeV 2024-01-04 16:42:15 -05:00
parent 6217b13504
commit bde327be02
Signed by: TakeV
GPG Key ID: A64F41345C7400AF
1 changed files with 8 additions and 0 deletions

View File

@ -37,6 +37,14 @@
(define (directory? file-name)
(eq? (stat:type (stat file-name)) 'directory))
(define (get-payload-for-path path routing-table)
"Returns the first payload that matches the routing-table path"
(let ((filtered-table
(filter (lambda (routing-entry)
(not (equal? path (uri-path (car routing-entry)))))
routing-table)))
(cdr (car filtered-table))))
(define (serve-file path)
(define %prefix `(,(getcwd) "public"))
(define (prepend-prefix path) (string-join (append %prefix `(,path)) file-name-separator-string))