import zio.http._
import zio.http.Server
import zio._
object ConcreteEntity extends App {
case class CreateUser(name: String)
case class UserCreated(id: Long)
val user: Http[Any, Nothing, CreateUser, UserCreated] =
Http.collect[CreateUser] { case CreateUser(_) =>
UserCreated(2)
}
val app: HttpApp[Any, Nothing] =
user
.contramap[Request](req => CreateUser(req.path.toString))
.map(userCreated => Response.text(userCreated.id.toString))
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
Server.start(8090, app).exitCode
}