Created
February 25, 2019 20:25
-
-
Save chamook/4f7fdb4a2257d6ae89027dfd2f374abf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 customJsonContentType mimeType data next (ctx : HttpContext) = | |
| sprintf "%s; charset=utf-8" mimeType |> ctx.SetContentType | |
| let serializer = ctx.GetJsonSerializer() | |
| serializer.SerializeToBytes data | |
| |> ctx.WriteBytesAsync | |
| type CustomNegotiationConfig (baseConfig : INegotiationConfig) = | |
| interface INegotiationConfig with | |
| member __.UnacceptableHandler = | |
| baseConfig.UnacceptableHandler | |
| member __.Rules = | |
| dict [ | |
| "*/*" , json | |
| "application/json" , json | |
| "application/vnd.chamook.mini-colours+json", | |
| customJsonContentType "application/vnd.chamook.mini-colours+json" | |
| ] | |
| let configureServices (services : IServiceCollection) = | |
| services.AddGiraffe() |> ignore | |
| CustomNegotiationConfig(DefaultNegotiationConfig()) | |
| |> services.AddSingleton<INegotiationConfig> | |
| |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment