x80486
08/07/2018, 2:50 AMclass Response(val message: String, val path: String) {
val timestamp: Long = Instant.now().toEpochMilli()
var status: Int = 0
lateinit var error: String
companion object {
fun clientError(message: String, path: String): Response {
return Response(message, path).apply { status = 400; error = "Bad Request" }
}
fun serverError(message: String, path: String): Response {
return Response(message, path).apply { status = 500; error = "Internal Server Error" }
}
}
}
Shawn
08/07/2018, 3:39 AMstatus
and error
`var`s? Could you not just put them in the primary constructor and use named parameters?sealed class
could be useful here as far as matching and whatnot goResult<T>
pattern if that’s something you might be interested in