You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
788 B

  1. ---
  2. layout: docs
  3. title: "Outwatch Router"
  4. section: "home"
  5. ---
  6. Outwatch Router
  7. ===
  8. Route creation strategy was mostly taken from Http4s. To create paths and map them to pages:
  9. ```scala mdoc
  10. import outwatch.router._
  11. sealed abstract class Page
  12. case class RootPage() extends Page
  13. case class Login() extends Page
  14. case class Register() extends Page
  15. case class Profile(userId: String) extends Page
  16. case class NotFound() extends Page
  17. def routes: PartialFunction[Path, Page] = {
  18. case Root => RootPage()
  19. case Root / "login" => Login()
  20. case Root / "register" => Register()
  21. case Root / "profile" / userId => Profile(userId)
  22. case _ => NotFound()
  23. }
  24. routes(Root)
  25. routes(Root / "login")
  26. routes(Root / "profile" / "saopa98f")
  27. routes(Path("/profile/asd"))
  28. routes(Path("/apsinoasn"))
  29. ```