0

scala finch ライブラリを使用して API を構築しようとしています。

次の簡単なコードがあります。

package example

import io.finch._
import com.twitter.finagle.Http

object HelloWorld extends App {

  val api: Endpoint[String] = get("hello") { Ok("Hello, World!") }

  Http.serve(":8080", api.toService)
}

そして、次のような build.sbt ファイル:

name := "hello-finch"

version := "1.0"

scalaVersion := "2.10.6"

mainClass in (Compile, run) := Some("example.HelloWorld")

libraryDependencies ++= Seq(
  "com.github.finagle" %% "finch-core" % "0.10.0"
)

// found here: https://github.com/finagle/finch/issues/604
addCompilerPlugin(
  "org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
)

コードをコンパイルして実行すると、次のエラー メッセージが表示されます。

object Http is not a member of package com.twitter.finagle
[error] import com.twitter.finagle.Http
[error]        ^
[error] /Users/jamesk/Code/hello_finch/hello-finch/src/main/scala/example/Hello.scala:8: wrong number of type arguments for io.finch.Endpoint, should be 2
[error]   val api: Endpoint[String] = get("hello") { Ok("Hello, World!") }
[error]            ^
[error] /Users/jamesk/Code/hello_finch/hello-finch/src/main/scala/example/Hello.scala:8: not found: value get
[error]   val api: Endpoint[String] = get("hello") { Ok("Hello, World!") }
[error]                               ^
[error] /Users/jamesk/Code/hello_finch/hello-finch/src/main/scala/example/Hello.scala:10: not found: value Http
[error]   Http.serve(":8080", api.toService)
[error]   ^
[error] four errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Aug 15, 2017 12:56:01 PM

この時点で、私はアイデアを使い果たしています。これは良いライブラリのように見えますが、機能させるのは大変です。どんな助けでも大歓迎です。

4

1 に答える 1