Created
April 7, 2018 23:14
-
-
Save reckenrode/b0afc3d51622732a438f533792edac90 to your computer and use it in GitHub Desktop.
Router databinding configuration for my website
This file contains 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 router = try container.make(Router.self) | |
let blog = try container.make(BlogController.self) | |
router.get("blog", use: Template(path: "Blog/listing") | |
.bind(blog.posts, to: "posts") | |
.bind(blog.isOldestFirst, to: "oldest-first").fn()) | |
router.get("blog", ":author", use: Template(path: "Blog/author-post").fn()) | |
router.post("blog", ":save", use: (blog.save >>> { $0.redirect(to: "/blog") })) | |
router.get("blog", String.parameter, use: Template(path: "Blog/view-post") | |
.bindObject(blog.post).fn()) | |
return .done(on: container) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment