Replace the response with some value

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?

What library are you using? (Looks like maybe Play?)

Can you use Markdown to post properly indented code? It’s hard to read without the indentation.

What’s wrong with complete(resp.replace(“oneString”,“Other”))? Does it give you a compile-time error, unexpected runtime behavior, or what? What’s the roadblock you’re hitting?