Created
December 8, 2016 06:27
-
-
Save kateinoigakukun/d1c42ef8432120a6d899d7bc1291c921 to your computer and use it in GitHub Desktop.
イニシャライザを書くのが無駄なんだよな #CodePiece
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
import Kitura | |
let router = Router() | |
class RouteMapping1: RouteMapping { | |
static var format: MappingFormat { | |
return ("status"/String.self/Int.self) | |
} | |
var user_name: String | |
var id : Int | |
required init(matched: [MatchedType], query: [String : String]) { | |
self.user_name = matched[0].result() | |
self.id = matched[1].result() | |
} | |
} | |
router.get(RouteMapping1.self) { | |
result, response, next in | |
response.send("\(result.user_name) \(result.id)") | |
next() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment