Skip to content

Instantly share code, notes, and snippets.

@mdedetrich
Created October 26, 2013 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdedetrich/7164288 to your computer and use it in GitHub Desktop.
Save mdedetrich/7164288 to your computer and use it in GitHub Desktop.
Sample server
get("/") {
contentType="text/html"
jade("index")
}
// get("/:page") {
// findTemplate(params("page")) map { path =>
// contentType = "text/html"
// jade(path)
// } orElse serveStaticResource() getOrElse resourceNotFound()
// }
get("/*") {
val query = multiParams("splat").head
if (query.endsWith(".js")
|| query.endsWith(".css")
|| query.endsWith(".png")
|| query.endsWith(".jpeg")
|| query.endsWith(".jpg")
|| query.endsWith(".gif")
){
serveStaticResource()
} else {
contentType="text/html"
jade("index")
}
}
get("/partials/:page") {
contentType="text/html"
jade("/partials/%s.jade" format params("page"), "layout" -> "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment