From 886d8be8bb9f82ad317283274239158d74f17946 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Thu, 2 Jan 2020 17:38:44 +0200 Subject: [PATCH] fsharp(todolist-api): feat: todo deleting Signed-off-by: prescientmoon --- fsharp/todolist-api/src/App.fs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fsharp/todolist-api/src/App.fs b/fsharp/todolist-api/src/App.fs index 61fdedb..661e939 100644 --- a/fsharp/todolist-api/src/App.fs +++ b/fsharp/todolist-api/src/App.fs @@ -55,11 +55,19 @@ module App = 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 [ pathScan "/todos/%i" (fun (id) -> choose [ GET >=> todoById id PUT >=> updateTodo id PATCH >=> patchTodo id + DELETE >=> deleteTodo id ])] []