Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created April 10, 2018 09:49
Show Gist options
  • Save samueleresca/324433822e54aa297c6e9f794cf6b8e1 to your computer and use it in GitHub Desktop.
Save samueleresca/324433822e54aa297c6e9f794cf6b8e1 to your computer and use it in GitHub Desktop.
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