jackmiras
02/21/2017, 1:57 PMoverride fun post(req: Request, res: Response): Any {
val platform = req.bodyAsObject() as Platform
if (platform.isValid()) {
PlatformRepository().save(platform)
return object { val message = "Platform created" ; val status = 201 }
} else {
return renderInvalidParams()
}
}
I could avoid doing the if else
statement by using functions as callback... just like this:
override fun post(req: Request, res: Response): Any {
req.bodyAsObject(success = {
PlatformRepository().save(platform)
return object { val message = "Platform created" ; val status = 201 }
}, failure = {
return renderInvalidParams()
})
}
mg6maciej
02/21/2017, 2:06 PMif
there. You are hiding it, adding abstraction that doesn't seem to solve any of: 1) having less client code, 2) having client code that is easier to understand (actually doing the opposite here imo), 3) having client code matching domain more closely (i.e. DSL)jackmiras
02/21/2017, 2:11 PMjackmiras
02/21/2017, 2:11 PMmg6maciej
02/21/2017, 2:12 PMmg6maciej
02/21/2017, 2:13 PMjackmiras
02/21/2017, 2:28 PM