Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 16:24
    codecov-commenter commented #1244
  • 16:16
    custommonkey synchronize #1244
  • 16:07
    custommonkey synchronize #1244
  • 15:23
    custommonkey opened #1244
  • Jul 03 18:44
    codecov-commenter commented #1243
  • Jul 03 18:37
    scala-steward opened #1243
  • Jun 29 20:07
    MaximilianoFelice commented #1237
  • Jun 27 23:26
    codecov-commenter commented #1242
  • Jun 27 23:17
    scala-steward opened #1242
  • Jun 24 04:23
    codecov-commenter commented #1241
  • Jun 24 04:17
    scala-steward opened #1241
  • Jun 19 23:19
    codecov-commenter commented #1240
  • Jun 19 23:13
    scala-steward opened #1240
  • Jun 19 03:01
    scala-steward opened #1239
  • Jun 13 11:21
    olib963 commented #1230
  • Jun 12 18:26
    codecov-commenter commented #1238
  • Jun 12 18:20
    scala-steward opened #1238
  • Jun 10 12:00
    rpless closed #1229
  • Jun 10 12:00
    rpless commented #1229
  • Jun 10 11:43
    sergeykolbasov closed #997
Dino Fancellu

I'm trying to return a 404 with a phrase that is not simple "Not Found"

This doesn't change the phrase

Output.failure(new Exception("Image not found"), Status.NotFound)


NotFound(new Exception("Image not found")

I get a 404 just fine. But I want the phrase to be as in the exception. Raw header is

HTTP/1.1 404 Not Found\r\nDate: Mon, 30 Mar 2020 11:51:40 GMT\r\nServer: Finch\r\nContent-Length: 0\r\n\r\n

Frederick Cai

@fancellu Me again 😄 You need to implement your own implicit Encoder[Exception], and ensure it is in scope when calling toService / toServiceAs on your endpoint(s)


Dino Fancellu

I do

  implicit val encodeException: Encoder[Exception] = Encoder.instance(e =>
    Json.obj("exception" -> Json.fromString(e.getMessage)))

What would I need to do to get it to put the getMessage into the HTTP reason?

Currently it says

HTTP/1.1 404 Not Found


Why does returning twitter's Future from endpoint with Endpoint[IO,?] type works? Using finchx 0.32.1

For example:

import cats.effect.IO
import{Event, WebhookError}
import com.twitter.util.Future
import com.twitter.util.logging.Logging
import io.finch.{Endpoint, Output, Ok, NoContent}
//import io.finch.catsEffect._
import io.finch.circe._
import shapeless.HNil
import io.circe.Json
//import io.catbird.util.twitterFutureInstance

object LokaliseWebhookEndpoint extends Logging {

  def apply(ipRangeEndpoint: Endpoint[IO,HNil], webhookEventHandler: WebhookEventHandler): Endpoint[IO,Unit] =
    Endpoint[IO].post(Endpoint[IO].path("webhook") :: ipRangeEndpoint :: Endpoint[IO].jsonBody[Json]) { body: Json =>
      if (body == Json.arr(Json.fromString("ping"))) {
      } else {
        val event =[Event].getOrElse(throw new RuntimeException())
        webhookEventHandler.handleEvent(event) map {
          case Right(_) => NoContent[Unit]
          case Left(err) => {
            Output.failure(new RuntimeException(err.message), err.status)


webhookEventHandler.handleEvent returns a twitter Future

Sergey Kolbasov
@htch there is an implicit coversion of Twitter Future -> Anything with Async
it lives inside of ToAsync and is available only for method endpoints, such as get("foo") { ... }
Kenneth Monteiro
anyone can point me in the right direction for a finch refined error message
how do i get one in the contentResponse
for paramOption[NonEmptyString]("marketingsource") it returns a BadRequest for a empty string but no error message
these are my imports import io.finch.refined._ import io.circe.refined._ // needed import import eu.timepit.refined.types.string.NonEmptyString
Kevin Pei

Hey guys, is it possible to flatten up nested Endpoints?

Let's say I have something like

(param[Int]("foo")).map {
   foo: Int => new fooEndpoint(foo)

The return type is an Endpoint[Endpoint[SomeResponseClass]]

Sergey Kolbasov

Hi @ManiacViper

You should define custom Encode[Exception] implicit instance and provide it at the call of .toService. Default encoding of all the exceptons is a blank page

@kpei No, it's not possible as endpoint is not monadic, but applicative. What's your use case?
Dino Fancellu

Does anyone know if Finch supports web sockets? Or some Finagle based code?

I see but that project is inactive. Thanks

Nicolas Rinaudo
This might be a silly question, but I see:
has this not been pushed to maven central, or is not hosted there anymore?
Dino Fancellu
Any examples of Finch handling file upload? Or Finagle? Thanks
Sergey Kolbasov
@nrinaudo Are you sure you're checking for finchx artefact?
Nicolas Rinaudo
Ah, I'm pretty sure I'm not, I didn't realise the name of the project had changed!
Sergey Kolbasov
@fancellu Finch doesn't support websockets
@nrinaudo it's a temporary thing, as we've two artifacts atm: with Future and F[_] (or finchx)
Nicolas Rinaudo
right. and the one with Future is not being updated anymore?
Sergey Kolbasov
Next release is going to end the deprecation cycle for Future one and finchx will be gone as well, so there will be only finch
Nicolas Rinaudo
so if I want support for 2.13, later versions of circe, ... I need to move to finchx temporarily
Sergey Kolbasov
Nicolas Rinaudo
Understood, thank you.
Dino Fancellu

I have some Option fields in my case class, when they are none the Json from Circe says null. e.g. "eventId":null

How do I tell it to simply emit nothing for that field? Thanks

@fancellu implicit val printer = Printer.noSpaces.copy(dropNullValues = true)
Actually there's an object in the finch-circe package which should solve this:
Dino Fancellu

I can't get either to work. i.e. my options are coming back as null still


  import io.finch.circe.dropNullValues._

val videoCanned: Endpoint[IO, Video] = get(videoadmin :: "canned") {
    Ok(Video(9999,"canned","url","link", description = "canned"))

But the optional null fields still come back as :null

What am I doing wrong?


Dino Fancellu

Ah, got it working, just had to be careful with imports

Dermot Haughey
anyone know how I can test a finch endpoint in concert with a finagle filter in tests?
is that possible?
Sergey Kolbasov
@hderms you would need to convert endpoint to service, apply this service to filter and then send a Request in
Dermot Haughey
thanks @sergeykolbasov I ended up doing that
I now regret depending on a finagle filter I wrote to guarantee any uncaught exceptions would be formatted the proper way in the response
Sergey Kolbasov
mm, finch guarantees that compiled endpoint (one that you get with .compile) wouldn't throw within F[_] context and you need to take care only of Either[Throwable, Response]
Dermot Haughey
basically I'm trying to integration test our whole stack in a subset of our test cases
so I just wrote some stuff that lets me take an Endpoint and run a test as either a Finch endpoint or compile it to a Finagle service and run it
and it more or less works the same
Hi all
Is Finch compatible with
Ryan Plessner
hi @softshipper Finch uses cats internally and brings it into your project transitively. We don't incorporate many of the primitives from cats but there are some ways to
Dermot Haughey
so I'm using finch fs2 support, in particular I have an endpoint like post("foo" :: binaryBodyStream[fs2.Stream]) { body: fs2.Stream[IO, Array[Byte]] => //etc... }
which compiles fine and seems to do what I want. However, I am having trouble getting a call to this endpoint to not 404.
Dermot Haughey
in the documentation I saw: An [[Endpoint]] that matches chunked requests and lifts their content into a generic so I tried using Transfer-Encoding: chunked as a header, but I haven't had any luck
Dermot Haughey
seems like withStreaming(true) was the missing link in this case