Slide 31
Slide 31 text
Kitura 2.x Parsing
@dokun24
router.post(“/animals”, handler: store)
func store(animal: Animal, completion: (Animal?, RequestError?) ->
Void) -> Void {
if animal.save() {
completion(animal, nil)
} else {
completion(nil, RequestError(httpCode: .400))
}
}