Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello world not working #1022

Closed
octavz opened this issue Nov 5, 2018 · 5 comments
Closed

Hello world not working #1022

octavz opened this issue Nov 5, 2018 · 5 comments

Comments

@octavz
Copy link

octavz commented Nov 5, 2018

Hi, I am sure I am doing something wrong, but Finch is very unfriendly with first time users.

I couldn't find any template that works out of the box so I adapted:

import cats.effect.IO
import com.twitter.finagle.Http

object Main extends App with Endpoint.Module[IO] {
    val api: Endpoint[IO, String] = get("hello") { Ok("Hello, World!") }
    Http.server.serve(":8080", api.toServiceAs[Text.Plain])
}
scalaVersion := "2.12.7"

libraryDependencies ++= Seq(
  "org.typelevel" %% "cats-core" % "1.4.0",
  "org.typelevel" %% "cats-effect" % "1.0.0",
  // -- config
  "com.typesafe" % "config" % "1.3.3",
  // -- testing --
  "org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
  // -- Logging --
  "ch.qos.logback" % "logback-classic" % "1.2.3",
  "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
  // -- Finch --
  "com.github.finagle" %% "finch-core" % FinchVersion,
  "com.github.finagle" %% "finch-circe" % FinchVersion,
  // -- json/circe --
  "io.circe" %% "circe-core" % CirceVersion,
  "io.circe" %% "circe-generic" % CirceVersion,
  "io.circe" %% "circe-jawn" % CirceVersion
)

and I get

[error] /home/xxx/projects/scala/kafka-support/src/main/scala/org/demo/Main.scala:7:39: type Module is not a member of object io.finch.Endpoint
[error] object Main extends App with Endpoint.Module[IO] {
[error]                                       ^
[error] /home/xxx/projects/scala/kafka-support/src/main/scala/org/demo/Main.scala:8:14: wrong number of type arguments for io.finch.Endpoint, should be 1
[error]     val api: Endpoint[IO, String] = get("hello") { Ok("Hello, World!") }
[error]              ^
[error] /home/xxx/projects/scala/kafka-support/src/main/scala/org/demo/Main.scala:8:41: type mismatch;
[error]  found   : String("hello")
[error]  required: ?{def apply: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method augmentString in object Predef of type (x: String)scala.collection.immutable.StringOps
[error]  and method stringToPath in trait Paths of type (s: String)io.finch.Endpoint[shapeless.HNil]
[error]  are possible conversion functions from String("hello") to ?{def apply: ?}
[error]     val api: Endpoint[IO, String] = get("hello") { Ok("Hello, World!") }
[error]                                         ^
[error] /home/xxx/projects/scala/kafka-support/src/main/scala/org/demo/Main.scala:8:37: not found: value get
[error]     val api: Endpoint[IO, String] = get("hello") { Ok("Hello, World!") }

@sergeykolbasov
Copy link
Collaborator

Hi @octavz

What's the version of finch you're using?

@rpless
Copy link
Collaborator

rpless commented Nov 5, 2018

I believe the issue is using the finch-core and finch-circe modules with Module[IO]. Per the README, you'll need to use finchx-core and finchx-circe (note the x after finch in the artifact name) . The finch artifacts are meant to support the old style of creating endpoints that are bound to the future implementation.

@vkostyukov
Copy link
Collaborator

vkostyukov commented Nov 6, 2018

Hey @octavz! Try looking at https://github.com/finch/finch.g8 that I composed today. It has instructions on how to generate a barebones Finch project that compiles and runs.

@octavz
Copy link
Author

octavz commented Nov 7, 2018

@vkostyukov ty, I tested with finchx and it builds, however i got the netty classpath issue.
I will check the gitter8 template, ty.

@monksy
Copy link

monksy commented Dec 11, 2021

With the example I'm seeing + updated dependencies:

overloaded method apply with alternatives:
[error]   (mapper: io.finch.internal.Mapper[cats.effect.IO,shapeless.HNil])io.finch.Endpoint[cats.effect.IO,mapper.Out] <and>
[error]   (input: io.finch.Input)io.finch.Endpoint.Result[cats.effect.IO,shapeless.HNil]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants