diff --git a/src/main/scala/com/ing/wbaa/rokku/proxy/RokkuS3Proxy.scala b/src/main/scala/com/ing/wbaa/rokku/proxy/RokkuS3Proxy.scala index c0319898..1b09113e 100644 --- a/src/main/scala/com/ing/wbaa/rokku/proxy/RokkuS3Proxy.scala +++ b/src/main/scala/com/ing/wbaa/rokku/proxy/RokkuS3Proxy.scala @@ -5,14 +5,14 @@ import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.server.Directives._ import com.ing.wbaa.rokku.proxy.api.directive.ProxyDirectives.cors -import com.ing.wbaa.rokku.proxy.api.{ HealthService, OptionService, PostRequestActions, ProxyService } +import com.ing.wbaa.rokku.proxy.api.{ HealthService, OptionService, PostRequestActions, ProxyService, TestService } import com.ing.wbaa.rokku.proxy.config.HttpSettings import com.typesafe.scalalogging.LazyLogging import scala.concurrent.{ ExecutionContext, Future } import scala.util.{ Failure, Success } -trait RokkuS3Proxy extends LazyLogging with ProxyService with PostRequestActions with HealthService with OptionService { +trait RokkuS3Proxy extends LazyLogging with ProxyService with PostRequestActions with HealthService with OptionService with TestService { protected[this] implicit def system: ActorSystem @@ -23,7 +23,7 @@ trait RokkuS3Proxy extends LazyLogging with ProxyService with PostRequestActions // The routes we serve. final val allRoutes = cors() { - healthRoute ~ optionRoute ~ proxyServiceRoute + testRoute ~ healthRoute ~ optionRoute ~ proxyServiceRoute } // Details about the server binding. diff --git a/src/main/scala/com/ing/wbaa/rokku/proxy/api/TestService.scala b/src/main/scala/com/ing/wbaa/rokku/proxy/api/TestService.scala new file mode 100644 index 00000000..1e23b42e --- /dev/null +++ b/src/main/scala/com/ing/wbaa/rokku/proxy/api/TestService.scala @@ -0,0 +1,43 @@ +package com.ing.wbaa.rokku.proxy.api + +import akka.http.scaladsl.model.StatusCodes +import akka.http.scaladsl.server.Directives._ +import akka.http.scaladsl.server.Route +import com.ing.wbaa.rokku.proxy.data.RequestId +import com.ing.wbaa.rokku.proxy.handler.LoggerHandlerWithId + +trait TestService { + + private val logger = new LoggerHandlerWithId + + final val testRoute: Route = + path("test200") { + get { + parameters("timeout".as[Long]) { (timeout) => + logger.debug("start test200")(RequestId("test200")) + Thread.sleep(timeout) + logger.debug("stop test200")(RequestId("test200")) + complete(StatusCodes.OK -> "test") + } + } + } ~ path("test502") { + get { + parameters("timeout".as[Long]) { (timeout) => + logger.debug("start test502")(RequestId("test200")) + Thread.sleep(timeout) + logger.debug("stop test502")(RequestId("test200")) + complete(StatusCodes.BadGateway -> "502") + } + } + } ~ path("test503") { + get { + parameters("timeout".as[Long]) { (timeout) => + logger.debug("start test503")(RequestId("test503")) + Thread.sleep(timeout) + logger.debug("stop test503")(RequestId("test503")) + complete(StatusCodes.ServiceUnavailable -> "503") + } + } + } + +}