Permalink
Browse files

serve raw files as strings if unresolvable via asset path (gist css/js)

  • Loading branch information...
1 parent d6261d2 commit 4c2573b7328db1551e8a8c81247b62571ee24a7b @softprops committed May 4, 2012
Showing with 6 additions and 2 deletions.
  1. +3 −2 core/src/main/scala/Resolver.scala
  2. +3 −0 server/src/main/scala/Projector.scala
@@ -29,8 +29,9 @@ class GistHttpResolver(id: String) extends Resolver {
case s => sys.error("unexpected response structure %s" format s)
}
lazy val configuration = files("conf.json")
- def resolve(p: String) = files.get(p.split('/').last)
- def exists(p: String) = files isDefinedAt p.split('/').last
+ def last(p: String) = p.split('/').last
+ def resolve(p: String) = files.get(last(p))
+ def exists(p: String) = files isDefinedAt last(p)
}
class FileSystemResolver(uri: URI) extends Resolver {
@@ -9,5 +9,8 @@ class Projector(uri: URI) extends Renderer(uri) with unfiltered.filter.Plan {
def intent = {
case Path("/") => HtmlContent ~>
ResponseString(renderDefault)
+ case Path(p) =>
+ if(exists(p)) resolve(p).map(ResponseString).getOrElse(Pass)
+ else Pass
}
}

0 comments on commit 4c2573b

Please sign in to comment.