{"action":"created","issue":{"url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/issues/178","repository_url":"https://api.github.com/repos/giraffe-fsharp/Giraffe","labels_url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/issues/178/comments","events_url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/issues/178/events","html_url":"https://github.com/giraffe-fsharp/Giraffe/issues/178","id":282635641,"number":178,"title":"Make JSON serializer configurable","user":{"login":"alfonsogarciacaro","id":8275461,"avatar_url":"https://avatars0.githubusercontent.com/u/8275461?v=4","gravatar_id":"","url":"https://api.github.com/users/alfonsogarciacaro","html_url":"https://github.com/alfonsogarciacaro","followers_url":"https://api.github.com/users/alfonsogarciacaro/followers","following_url":"https://api.github.com/users/alfonsogarciacaro/following{/other_user}","gists_url":"https://api.github.com/users/alfonsogarciacaro/gists{/gist_id}","starred_url":"https://api.github.com/users/alfonsogarciacaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfonsogarciacaro/subscriptions","organizations_url":"https://api.github.com/users/alfonsogarciacaro/orgs","repos_url":"https://api.github.com/users/alfonsogarciacaro/repos","events_url":"https://api.github.com/users/alfonsogarciacaro/events{/privacy}","received_events_url":"https://api.github.com/users/alfonsogarciacaro/received_events","type":"User","site_admin":false},"labels":[{"id":749055897,"url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/labels/refactoring%20request","name":"refactoring request","color":"9927e5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/milestones/2","html_url":"https://github.com/giraffe-fsharp/Giraffe/milestone/2","labels_url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/milestones/2/labels","id":2697829,"number":2,"title":"RC1","description":"Release Candidate 1","creator":{"login":"dustinmoris","id":4580714,"avatar_url":"https://avatars2.githubusercontent.com/u/4580714?v=4","gravatar_id":"","url":"https://api.github.com/users/dustinmoris","html_url":"https://github.com/dustinmoris","followers_url":"https://api.github.com/users/dustinmoris/followers","following_url":"https://api.github.com/users/dustinmoris/following{/other_user}","gists_url":"https://api.github.com/users/dustinmoris/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinmoris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinmoris/subscriptions","organizations_url":"https://api.github.com/users/dustinmoris/orgs","repos_url":"https://api.github.com/users/dustinmoris/repos","events_url":"https://api.github.com/users/dustinmoris/events{/privacy}","received_events_url":"https://api.github.com/users/dustinmoris/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":6,"state":"open","created_at":"2017-08-12T14:49:30Z","updated_at":"2017-12-23T16:42:08Z","due_on":null,"closed_at":null},"comments":42,"created_at":"2017-12-16T16:59:38Z","updated_at":"2017-12-24T14:43:25Z","closed_at":null,"author_association":"NONE","body":"Reference https://github.com/SAFE-Stack/SAFE-BookStore/pull/255#issuecomment-352194907\r\n\r\nSome users may have particular needs in JSON serialization. For example, when interacting with Fable apps you need to [pass the Fable.JsonConverter](http://fable.io/docs/interacting.html#json-serialization). This means you cannot use the default http handlers in Giraffe and they need to be customized. Two alternatives have been proposed to fix but they both have inconveniences:\r\n\r\n- Write a custom `negotiate` function, but users need to remember to use it every time (like `Successful.ok (myCustomNegotiate promos) next ctx`) and the compiler won't help them when they don't.\r\n- Create a Giraffe.Fable package, but it looks too big an effort to create a full package to override **all** Giraffe handlers only in order to pass a custom converter to JSON serialization settings.\r\n\r\nInstead of those :point_up: would you be OK with making the [defaultJsonSerializerSettings](https://github.com/giraffe-fsharp/Giraffe/blob/60c29e2e8d21886b853066fef2492b8450f12a87/src/Giraffe/Common.fs#L40) configurable? And if so, what would be best way to do it (besides making that field mutable)?"},"comment":{"url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/issues/comments/353787989","html_url":"https://github.com/giraffe-fsharp/Giraffe/issues/178#issuecomment-353787989","issue_url":"https://api.github.com/repos/giraffe-fsharp/Giraffe/issues/178","id":353787989,"user":{"login":"dustinmoris","id":4580714,"avatar_url":"https://avatars2.githubusercontent.com/u/4580714?v=4","gravatar_id":"","url":"https://api.github.com/users/dustinmoris","html_url":"https://github.com/dustinmoris","followers_url":"https://api.github.com/users/dustinmoris/followers","following_url":"https://api.github.com/users/dustinmoris/following{/other_user}","gists_url":"https://api.github.com/users/dustinmoris/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinmoris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinmoris/subscriptions","organizations_url":"https://api.github.com/users/dustinmoris/orgs","repos_url":"https://api.github.com/users/dustinmoris/repos","events_url":"https://api.github.com/users/dustinmoris/events{/privacy}","received_events_url":"https://api.github.com/users/dustinmoris/received_events","type":"User","site_admin":false},"created_at":"2017-12-24T14:43:25Z","updated_at":"2017-12-24T14:43:25Z","author_association":"OWNER","body":"Just pushed another change to the feature branch which can be used for evaluation. I added an [`INegotiationConfig`](https://github.com/giraffe-fsharp/Giraffe/commit/51c27a93efa568b0090b7b5ea380ee1d725cd386#diff-8f2eec86bef243297319c406614b0989R9) interface which can be used to customise the default `negotiate` handler as well.\r\n\r\nAlso someone more clever than me pointed out that we shouldn't register a type in Giraffe which doesn't belong to Giraffe like I initially did with the `JsonSerializerSettings`. This could cause conflicts or problems with other middleware which might also try to register the same type. In Giraffe we should only register types which are owned by Giraffe, so the preferred way to customize the Json serializer would be:\r\n\r\nKeep JSON.NET, but change settings:\r\n```fsharp\r\nlet configureServices (services : IServiceCollection) =\r\n    let customSettings = new JsonSerializerSettings()\r\n    services.AddGiraffe().AddSingleton<IJsonSerializer>(NewtonsoftJsonSerializer(customSettings))\r\n```\r\n\r\nComplete different serializer:\r\n```fsharp\r\nlet configureServices (services : IServiceCollection) =\r\n    services.AddGiraffe().AddSingleton<IJsonSerializer, MyOwnJsonSerializer>()\r\n```"}}
{"actor":{"display_login":"dustinmoris"}}