Skip to content
Permalink
Browse files

posts: delete post via json

  • Loading branch information...
3v0k4 committed Aug 17, 2019
1 parent 4922c8d commit 166aa28741fe532ae664308a2af4b28638b6d560
Showing with 7 additions and 0 deletions.
  1. +1 −0 config/routes
  2. +1 −0 src/Foundation.hs
  3. +5 −0 src/Handler/Posts.hs
@@ -17,3 +17,4 @@
/posts/#PostId PostR DELETE

/api/posts ApiPostsR GET POST
/api/posts/#PostId ApiPostR DELETE
@@ -182,6 +182,7 @@ instance Yesod App where
isAuthorized PostsR _ = isAuthenticated
isAuthorized ApiPostsR _ = isAuthenticated
isAuthorized (PostR postId) _ = isOwner postId
isAuthorized (ApiPostR postId) _ = isOwner postId

-- This function creates static content files in the static folder
-- and names them based on a hash of their content. This allows
@@ -123,3 +123,8 @@ deletePostR :: PostId -> Handler Html
deletePostR postId = do
_ <- runDB $ delete postId
redirect PostsR

deleteApiPostR :: PostId -> Handler Value
deleteApiPostR postId = do
_ <- runDB $ delete postId
return Null

0 comments on commit 166aa28

Please sign in to comment.
You can’t perform that action at this time.