casereq @POST -> Root/ "products" => req .as[Product] .flatMap { p => for { cnt <- repo.saveProduct(p) res <- cnt match { case 0 => NotFound() case _ => InternalServerError() } } yield res } .handleErrorWith { case InvalidMessageBodyFailure(_, _) => BadRequest() }{ "id": "ProductId(UUID)", "names": [ { "name":"A non empty string", "lang": "ISO-639-1 Code" } ] }