{"id":9395,"date":"2014-08-24T15:50:25","date_gmt":"2014-08-24T19:50:25","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=9395"},"modified":"2014-08-24T15:50:59","modified_gmt":"2014-08-24T19:50:59","slug":"type-safe-url-routes-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/08\/24\/type-safe-url-routes-in-swift\/","title":{"rendered":"Type-safe URL Routes in Swift"},"content":{"rendered":"<p><a href=\"http:\/\/chris.eidhof.nl\/posts\/typesafe-url-routes-in-swift.html\">Chris Eidhof<\/a>:<\/p>\n<blockquote cite=\"http:\/\/chris.eidhof.nl\/posts\/typesafe-url-routes-in-swift.html\"><p>I think it&rsquo;s a really nice way of building APIs. The Github enum makes it very clear which endpoints are available, and the form of their parameters. By defining these things once, we can make it much harder for users of this API to make mistakes. For example, it&rsquo;s not possible to pass in a <code>nil<\/code> username, because the <code>UserProfile<\/code> takes a non-optional string. If we wanted to add optional parameters, we have to be explicit about that.<\/p><p>The other nice thing is that all of the above code is independent of any networking library.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Chris Eidhof: I think it&rsquo;s a really nice way of building APIs. The Github enum makes it very clear which endpoints are available, and the form of their parameters. By defining these things once, we can make it much harder for users of this API to make mistakes. For example, it&rsquo;s not possible to pass [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[74,71,901,50],"class_list":["post-9395","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-opensource","tag-programming","tag-swift-programming-language","tag-webapi"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=9395"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9395\/revisions"}],"predecessor-version":[{"id":9397,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9395\/revisions\/9397"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=9395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=9395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=9395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}