I have a controller that should execute the request to another site and get a response. How to do it?
@Singleton
class MeController @Inject()(cc: ControllerComponents, actorSystem: ActorSystem)(implicit exec: ExecutionContext) extends AbstractController(cc) {
def message = Action.async {
val url = "https://another.site/data"
val httpRequest = ???
Future(httpRequest.response.body).map { msg => Ok(msg) }
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.