Skip to content

Commit

Permalink
add root path
Browse files Browse the repository at this point in the history
  • Loading branch information
fluency03 committed Apr 16, 2018
1 parent cec57cc commit 0cb4720
Showing 1 changed file with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import akka.event.Logging
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.directives.MethodDirectives.{delete, get, post}
import akka.http.scaladsl.server.directives.MethodDirectives.post
import akka.http.scaladsl.server.directives.RouteDirectives.complete
import com.fluency03.blockchain.Util._

Expand All @@ -14,21 +14,27 @@ trait GenericRoutes extends Routes {
lazy val log = Logging(system, classOf[GenericRoutes])

lazy val genericRoutes: Route =
pathPrefix("generic") {
path("hash-of-string") {
post {
entity(as[Input]) { in => complete((StatusCodes.Created, hashOf(in.data))) }
}
} ~
path("base64-of-string") {
post {
entity(as[Input]) { in => complete((StatusCodes.Created, toBase64(in.data))) }
}
} ~
path("string-of-base64") {
post {
entity(as[Input]) { in => complete((StatusCodes.Created, fromBase64(in.data))) }
}
pathSingleSlash {
get {
complete("Welcome to Blockchain in Scala!")
}
}
} ~
pathPrefix("generic") {
path("hash-of-string") {
post {
entity(as[Input]) { in => complete((StatusCodes.Created, hashOf(in.data))) }
}
} ~
path("base64-of-string") {
post {
entity(as[Input]) { in => complete((StatusCodes.Created, toBase64(in.data))) }
}
} ~
path("string-of-base64") {
post {
entity(as[Input]) { in => complete((StatusCodes.Created, fromBase64(in.data))) }
}
}
}

}

0 comments on commit 0cb4720

Please sign in to comment.