繁体   English   中英

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

[英]Play framework, How to send HTTP GET/POST request to another site

我有一个 controller 应该执行对另一个站点的请求并得到响应。 怎么做?

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

  }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM