diff options
Diffstat (limited to 'haunt/api.scm')
| -rw-r--r-- | haunt/api.scm | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/haunt/api.scm b/haunt/api.scm index 1d275f8..b1db096 100644 --- a/haunt/api.scm +++ b/haunt/api.scm @@ -21,6 +21,7 @@ (jakob dynamic capabilities gallery) (jakob dynamic capabilities rsvp) (jakob dynamic logging) + (jakob dynamic rate-limiter) (srfi srfi-1) (web request) (web response) @@ -39,17 +40,18 @@ (originating-ip (assoc-ref (request-headers request) 'X-Forwarded-For)) (args (uri-query (request-uri request)))) (log-append! 'info (format #f "~a ~a (~a) (~a)" method endpoint args originating-ip))) - ((match (cons (request-method request) endpoint) - (('GET "comment-form" _) get-comment-form) - ('(GET "challenge" "proof-of-work") make-pow-challenge!) - ('(GET "challenge" "captcha") make-captcha-challenge!) - ;; ('(GET "comments") get-comments) - (('POST "comment") put-comment) - (('GET "gallery") get-gallery) - (('GET "gallery" "image") get-image) - (('GET "rsvp" "event-info") get-event-info) - (('POST "rsvp") post-event-rsvp) - (_ (lambda (. args) (not-found request)))) + ((rate-limit-wrap + (match (cons (request-method request) endpoint) + (('GET "comment-form" _) get-comment-form) + ('(GET "challenge" "proof-of-work") make-pow-challenge!) + ('(GET "challenge" "captcha") make-captcha-challenge!) + ;; ('(GET "comments") get-comments) + (('POST "comment") put-comment) + (('GET "gallery") get-gallery) + (('GET "gallery" "image") get-image) + (('GET "rsvp" "event-info") get-event-info) + (('POST "rsvp") post-event-rsvp) + (_ (lambda (. args) (not-found request))))) request body)) (define (main-request-handler request body) |