diff options
| -rw-r--r-- | main.scm | 19 | 
1 files changed, 11 insertions, 8 deletions
| @@ -234,6 +234,13 @@                           (map (cut post current-user <>) comments))                        ,(if current-user (new-post-form (id p)) '()))))) +(define (post-path id)  +  (if +    (and id +         (not (equal? "" id))) +    (string-append "/posts/" id) +    "/")) +  (define routes    `( @@ -286,11 +293,7 @@                             [user (get-current-user)]                             [success? (if user (create-post user content parent-id) #f)])                          (send-response -                               headers: `((location ,(if -                                                       (and parent-id -                                                            (not (equal? "" parent-id))) -                                                       (string-append "/posts/" parent-id) -                                                       "/"))) +                               headers: `((location ,(post-path parent-id)))                                 status: 'see-other                                 ))))      (GET (/ "") ,(lambda (rt)  @@ -314,12 +317,12 @@      (GET (/ "posts" ":id" "delete") ,(lambda (rt)                                 (let* ([current-user (get-current-user)]                                       [post-id (get-route-param rt "id")] +                                     [post (get-post post-id)]                                       [succeeded? (delete-post post-id current-user)])                                  (if succeeded?                                  (send-response -                                  headers: `((location "/")) -                                  status: 'see-other -                                  ) +                                  headers: `((location ,(post-path (parent-id post)))) +                                  status: 'see-other)                                  (send-status 'internal-server-error "Deletion Failed")))))      (GET (/ "posts") ,(lambda (rt) | 
