Remove unused file

This commit is contained in:
Zak Patterson 2019-02-04 00:02:45 -05:00
parent 489bb26504
commit 6f94fdd135
2 changed files with 14 additions and 36 deletions

View File

@ -7,12 +7,10 @@ section: "home"
Outwatch Router Outwatch Router
=== ===
Route creation strategy was mostly taken from Http4s. To create paths and map them to pages:
```scala mdoc ```scala mdoc
import cats._ import outwatch.router._
import cats.implicits._
import cats.Applicative
import cats.data.Kleisli
import outwatch.router._, Router._
sealed abstract class Page sealed abstract class Page
case class RootPage() extends Page case class RootPage() extends Page
@ -21,29 +19,18 @@ case class Register() extends Page
case class Profile(userId: String) extends Page case class Profile(userId: String) extends Page
case class NotFound() extends Page case class NotFound() extends Page
object Page{ def routes: PartialFunction[Path, Page] = {
def root: Page = RootPage() case Root => RootPage()
def login: Page = Login() case Root / "login" => Login()
def register: Page = Register() case Root / "register" => Register()
def profile(userId: String): Page = Profile(userId) case Root / "profile" / userId => Profile(userId)
def notFound: Page = NotFound() case _ => NotFound()
} }
def routes[F[_]: Applicative]: AppRouter[F, Page] = Kleisli[F, Path, Page] { routes(Root)
case Root => Page.root.pure[F] routes(Root / "login")
case Root / "login" => Page.login.pure[F] routes(Root / "profile" / "saopa98f")
case Root / "register" => Page.register.pure[F]
case Root / "profile" / userId => Page.profile(userId).pure[F]
case _ => Page.notFound.pure[F]
}
val router = routes[Id] routes(Path("/profile/asd"))
routes(Path("/apsinoasn"))
router.run(Root)
router.run(Root / "login")
router.run(Root / "profile" / "saopa98f")
router.run(Path("/profile/asd"))
router.run(Path("/apsinoasn"))
``` ```

View File

@ -1,9 +0,0 @@
package outwatch.router
import cats.data.Kleisli
object Router {
type AppRouter[F[_], A] = Kleisli[F, Path, A]
val AppRouter = Kleisli
}