Skip to content

Instantly share code, notes, and snippets.

@chamook
Created February 25, 2019 20:31
Show Gist options
  • Select an option

  • Save chamook/6561ca0b26e9053a050b144d69eb0ceb to your computer and use it in GitHub Desktop.

Select an option

Save chamook/6561ca0b26e9053a050b144d69eb0ceb to your computer and use it in GitHub Desktop.
type MiniColour = {
Id : string
Name : string
Hex : string
}
type MiniMyColoursDto = { Colours : MiniColour list }
let toMiniColour (c : Colour) = { MiniColour.Id = c.Id; Name = c.Name; Hex = c.Hex }
let getMyColours: HttpHandler =
fun next ctx ->
match ctx.TryGetRequestHeader "Accept" with
| Some x when x.Contains "application/vnd.chamook.mini-colours+json" ->
Successful.OK
{ MiniMyColoursDto.Colours = myColours |> List.map toMiniColour }
next
ctx
| _ ->
Successful.OK
{ MyColoursDto.Colours = myColours }
next
ctx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment