Created
April 14, 2018 11:07
-
-
Save samueleresca/20d22cd3d10d935ea513c9d64b9abec1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let labelUpdateHandler (id : int) = | |
fun (next : HttpFunc) (ctx : HttpContext) -> | |
task { | |
let context = ctx.RequestServices.GetService(typeof<LabelsContext>) :?> LabelsContext | |
let! label = ctx.BindJsonAsync<CreateUpdateLabelRequest>() | |
match label.HasErrors with | |
| Some msg -> return! (setStatusCode 400 >=> json msg) next ctx | |
| None -> | |
return! updateLabel context label.GetLabel id |> function | |
| Some l -> ctx.WriteJsonAsync l | |
| None -> (setStatusCode 400 >=> json "Label not updated") next ctx | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment