Skip to content

Instantly share code, notes, and snippets.

@jacobappleton
Created September 8, 2015 04:07
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 jacobappleton/235befc9236ca2f4ba0d to your computer and use it in GitHub Desktop.
Save jacobappleton/235befc9236ca2f4ba0d to your computer and use it in GitHub Desktop.
Spray routing example
val compilerRoute : Route =
path("") {
redirect("http://www.jacobappleton.io", StatusCodes.PermanentRedirect)
} ~
pathPrefix("app") {
pathPrefix("assets") {
getFromResourceDirectory("web/assets/")
} ~ {
getFromResource("web/index.html")
}
} ~
pathPrefix("api") {
path("regex") {
post {
entity(as[String]) { pattern =>
complete {
(regexWorker ? pattern).mapTo[RegexResponse]
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment