From 0cb47202985959abf24b8ec7b655c1d70bfeeea9 Mon Sep 17 00:00:00 2001 From: fluency03 Date: Tue, 17 Apr 2018 01:42:29 +0200 Subject: [PATCH] add root path --- .../blockchain/api/routes/GenericRoutes.scala | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/scala/com/fluency03/blockchain/api/routes/GenericRoutes.scala b/src/main/scala/com/fluency03/blockchain/api/routes/GenericRoutes.scala index 2160365..bc6ec5a 100644 --- a/src/main/scala/com/fluency03/blockchain/api/routes/GenericRoutes.scala +++ b/src/main/scala/com/fluency03/blockchain/api/routes/GenericRoutes.scala @@ -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._ @@ -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))) } + } + } + } + }