Play框架,如何将HTTP GET / POST请求发送到另一个站点

问题描述 投票:0回答:1

我有一个控制器,应该执行对另一个站点的请求并获得响应。怎么做?

@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) }

  }

}
scala playframework
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.