Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val jsonRoute = {
- import spray.httpx.SprayJsonSupport.sprayJsonMarshaller
- import spray.httpx.SprayJsonSupport.sprayJsonUnmarshaller
- import JsonImplicits._
- get {
- path("") {
- respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here
- complete {
- <html>
- <body>
- <h1>The <b>S4</b> - <i>Slick Spray Scala Stack</i> is running :-)</h1>
- </body>
- </html>
- }
- }
- } ~
- path("index") {
- respondWithMediaType(`text/html`) {
- complete {
- <html>
- <body>
- <h1>Fix this</h1>
- </body>
- </html>
- }
- }
- } ~
- path("index2") {
- respondWithMediaType(`text/html`) {
- complete {
- <html>
- <body>
- <h1>Fix this also</h1>
- </body>
- </html>
- }
- }
- }
- } ~
- // unmatchedPath { ump =>
- // redirect("bootstrap/%s" + ump, Found)
- // }
- get {
- // path("favicon.ico") {
- // complete(NotFound)
- // } ~
- path(Rest) { path =>
- getFromResource("bootstrap/%s" format path)
- } ~
- path("file") {
- getFromResource("application.conf")
- }
- } ~
- path("persons") {
- get { ctx =>
- ctx.complete {
- val result: List[Person] = m.getPersons()
- result
- }
- }
- } ~
- path("person") {
- authenticate(BasicAuth(CustomUserPassAuthenticator, "person-security-realm")) { userProfile =>
- post {
- entity(as[Person]) { person => ()
- val result: Person = m.addPerson(person)
- complete(result)
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement