Replace the response with some value

40 views
Skip to first unread message

venkatesh rasipuram

unread,
May 23, 2020, 3:22:04 AM5/23/20
to Akka User List
Hi Team, Can someone please help here? 


I wanted to replace the response content with some value. Here is my code

def someRoute: Route = path(“ci” / “anomaly” / “detection” / "location" / Segment / Segment / “units” / IntNumber) { (country, businessUnit, store) =>

  get {

    extractRequest { req =>

      val sbuUri = s”${someHost}/ci/anomaly/detection/location/${country}/${businessUnit}/units/${storeMap.getOrElse(store, store).toString}"

      onComplete(http.singleRequest(request = HttpRequest(uri = sbuUri, headers = req.headers))) {

        case Success(resp) => complete(resp)

        case Failure(ex) => complete((StatusCodes.InternalServerError, s"An error occurred: ${ex.getMessage}"))

      }

    }

  }

}



and I wanted to replace something like this

case Sucess(resp) => complete(resp.replace("oneString","Other"))

How can I achieve this one in scala http one?



Reply all
Reply to author
Forward
0 new messages