Skip to content

Commit 24a4f51

Browse files
committed
uses AR.either for create new tweet
1 parent 8c3608a commit 24a4f51

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/FsTweet.Web/Wall.fs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,14 @@ module Suave =
3737
printfn "%A" ex
3838
JSON.internalError
3939

40-
let handleCreateTweetResult result =
41-
either onCreateTweetSuccess onCreateTweetFailure result
42-
43-
let handleAsyncCreateTweetResult aResult =
44-
aResult
45-
|> Async.ofAsyncResult
46-
|> Async.map handleCreateTweetResult
47-
4840
let handleNewTweet createTweet (user : User) ctx = async {
4941
match JSON.deserialize ctx.request with
5042
| Success (PostRequest post) ->
5143
match Post.TryCreate post with
5244
| Success post ->
53-
let aCreateTweetResult = createTweet user.UserId post
5445
let! webpart =
55-
handleAsyncCreateTweetResult aCreateTweetResult
46+
createTweet user.UserId post
47+
|> AR.either onCreateTweetSuccess onCreateTweetFailure
5648
return! webpart ctx
5749
| Failure err ->
5850
return! JSON.badRequest err ctx

0 commit comments

Comments
 (0)