1
Fork 0

fsharp(todolist-api): feat: todo deleting

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2020-01-02 17:38:44 +02:00 committed by prescientmoon
parent ba40a9c203
commit 886d8be8bb
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -55,11 +55,19 @@ module App =
return! respondWithTodo todo ctx return! respondWithTodo todo ctx
}) })
let deleteTodo = withTodoById (fun (todo, dbContext) ->
fun ctx -> async {
do! Queries.deleteTodoById todo dbContext
return! respondWithTodo todo ctx
})
let mainWebPart: WebPart = choose [ let mainWebPart: WebPart = choose [
pathScan "/todos/%i" (fun (id) -> choose [ pathScan "/todos/%i" (fun (id) -> choose [
GET >=> todoById id GET >=> todoById id
PUT >=> updateTodo id PUT >=> updateTodo id
PATCH >=> patchTodo id PATCH >=> patchTodo id
DELETE >=> deleteTodo id
])] ])]
[<EntryPoint>] [<EntryPoint>]