Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait BlogSystem[A] {
- val postsDirectory: File
- def postFile[A](title: String): Option[File] =
- postsDirectory.some.filter(f => f.isFile && f.canRead)
- }
- object BlogPost {
- def unapply[A](title: String)(implicit ev:BlogSystem[A]): Option[BlogPost] = {
- ev.postFile(title).map(BlogPost(_))
- }
- }
- class BlogPlan[A] extends Plan with Scalate {
- def intent = Intent {
- case Path(Seg("post" :: BlogPost(post) :: Nil)) => Ok ~> ResponseString(post.file.toString)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement