LoginSignup
1
0

More than 5 years have passed since last update.

finatra 六歩目

Last updated at Posted at 2016-07-06

外部通信

http通信は以下のとおり。
httpsはoverride val sslHostname = ""を追加して色々試してるけどエラーになってよくわからん。

import com.twitter.finagle.builder.{ClientBuilder, ServerBuilder}
import com.twitter.finagle.http._
import com.twitter.finatra.http.Controller
import com.twitter.finatra.httpclient.modules.HttpClientModule
import com.twitter.finatra.json.FinatraObjectMapper

// ~中略~

  get("/api/request") { request: Request =>

    val httpClientModule = new HttpClientModule() {
      val dest = "fscoward.hateblo.jp:80"
      override val hostname = "fscoward.hateblo.jp:80"
    }
    val req = Request.apply(Version.Http11, Method.Get, "/")

    val httpClient = httpClientModule.provideHttpClient(FinatraObjectMapper.create(), httpClientModule.provideHttpService)
    for {
      r <- httpClient.execute(req)
    } yield {
      r
    }
  }

もしくは

↓でもいける

    val http = com.twitter.finagle.Http
    http.fetchUrl("http://fscoward.hateblo.jp")
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0