I’ve my routes method which is like this(inSome and inSomeStatus are functions with return type Route)
def routes(serviceSid: String): Route = {
path("Some") {
inSome(serviceSid)
} ~
path("SomeStatus") {
inSomeStatus(serviceSid)
}
}
I’m calling this routes function from here:
val routes: Route = {
pathPrefix("Gateway" / "Services" / sid[String] / "Market") { (serviceSid: String) =>
routes(serviceSid)
}
}
Now, I’ve a requirement that I want to return a XmlResponse with 200 status code regardless of the result of inSome and inSomeStatus functions(they call some other API whose response can be anything).
I came up with this, but the xml
val routes: Route = {
pathPrefix("Gateway" / "Services" / sid[ProxyServiceSid] / "Webhooks") { serviceSid =>
val responseBody: Route = routes(serviceSid) // Get the route for the specified serviceSid
complete(StatusCodes.OK, responseBody)
}
}
implicit val routeMarshaller: ToEntityMarshaller[Route] = Marshaller.fromResponse[Route] { route: Route =>
HttpResponse(StatusCodes.OK, entity = HttpEntity(ContentTypes.`text/xml(UTF-8)`, "Route response"))
}
But the routeMarshaller gives error saying Required -> HttpResponse; Found -> (Route)HttpResponse
.
Suggest fixing this code or can this be done in some other way? Thanks!!