Created
April 10, 2018 09:49
-
-
Save samueleresca/324433822e54aa297c6e9f794cf6b8e1 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
module Blog.FSharpWebAPI.Handlers | |
open Giraffe; | |
open Microsoft.AspNetCore.Http | |
open Blog.FSharpWebAPI.Models | |
open CompostionRoot | |
let labelsHandler = | |
fun (next : HttpFunc) (ctx : HttpContext) -> | |
getAll |> ctx.WriteJsonAsync | |
let labelHandler(id: int) = | |
fun (next : HttpFunc) (ctx : HttpContext) -> | |
getLabel id | |
|> function | |
| Some l -> ctx.WriteJsonAsync l | |
| None -> (setStatusCode 400 >=> json "label not found") next ctx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment