我有一个控制器,应该执行对另一个站点的请求并获得响应。怎么做?
@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) }
}
}