package example
import zio.http.Middleware.{csrfGenerate, csrfValidate}
import zio.http._
import zio.http.Server
import zio._
object CSRF extends App {
val privateApp = Http.collect[Request] { case Method.GET -> !! / "unsafeEndpoint" =>
Response.text("secure info")
} @@ csrfValidate()
val publicApp = Http.collect[Request] { case Method.GET -> !! / "safeEndpoint" =>
Response.text("hello")
} @@ csrfGenerate()
val app = publicApp ++ privateApp
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] =
Server.start(8090, app).exitCode
}