Created
December 9, 2016 09:48
-
-
Save kateinoigakukun/8f11c2f1ccc542569c38efd257b18e6b to your computer and use it in GitHub Desktop.
KituraExtension #CodePiece
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
class MainController: PageController { | |
typealias Routing = MainRouting | |
var context: [String : Any] { | |
return [ | |
"user": self.user, | |
"id": self.id | |
] | |
} | |
var user: String | |
var id: Int | |
required init(mappnig: MainController.Routing) { | |
self.user = mappnig.user | |
self.id = mappnig.id | |
} | |
} | |
class MainRouting: RouteMapping { | |
static var format: MappingFormat { | |
return (String.self/"status"/Int.self) | |
} | |
let user: String | |
let id: Int | |
required init(matched: [MatchedType], | |
query: [String : String]) { | |
self.user = matched[0].result() | |
self.id = matched[1].result() | |
} | |
} | |
router.get(controller: MainController.self) | |
router.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment