Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 13 09:38
    joroKr21 synchronize #1516
  • Aug 13 09:36
    joroKr21 synchronize #1516
  • Aug 13 09:36
    joroKr21 synchronize #1516
  • Aug 13 09:19
    joroKr21 synchronize #1515
  • Aug 13 09:09
    joroKr21 synchronize #1515
  • Aug 13 09:09
    joroKr21 synchronize #1515
  • Aug 13 09:02
    joroKr21 synchronize #1516
  • Aug 13 09:01
    joroKr21 opened #1516
  • Aug 13 08:16
    joroKr21 opened #1515
  • Aug 12 17:02

    joroKr21 on master

    Update scalafmt-core to 3.5.9 Merge pull request #1514 from s… (compare)

  • Aug 12 17:02
    joroKr21 closed #1514
  • Aug 12 14:39
    scala-steward opened #1514
  • Aug 12 11:33
    joroKr21 commented #1098
  • Aug 12 11:32
    joroKr21 commented #1112
  • Aug 12 11:28
    joroKr21 commented #1407
  • Aug 12 11:23
    joroKr21 opened #1513
  • Aug 11 08:47

    joroKr21 on better-close-for-tw

    (compare)

  • Aug 11 08:47

    joroKr21 on master

    Clean up examples to not use to… Complete bootstrap rework Modi… Cleanup Bootstrap and 3 more (compare)

  • Aug 11 08:47
    joroKr21 closed #1481
  • Aug 11 08:26
    joroKr21 synchronize #1481
Dermot Haughey
@hderms
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
@sergeykolbasov
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
@hderms
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
softshipper
@softshipper
Hi all
Is Finch compatible with https://typelevel.org/cats/?
Ryan Plessner
@rpless
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
@hderms
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
@hderms
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
@hderms
seems like withStreaming(true) was the missing link in this case
Chih
@Chih47911515_twitter
Hi all! I new to Finch! Tried to find some recent docs about polymorphic endpoints, but apparently, this is quite new and no docs were updated yet. I'm wondering does anyone has any working example to share on how to use Finch with ZIO? Thanks in advance!
1 reply
ComFreek
@ComFreek
If you process Options in your endpoint, what's the best practice to .getOrElse(return BadRequest(???)?
private def foo: Endpoint[IO, String] = get(path("debug")) {
  None.getOrElse(return BadRequest(???))
  Ok("test")
}
This does not typecheck since return will return the outer function (thus BadRequest(???) is expected to be of type Endpoint[IO, String])
But ideally, we would just return from the lambda passed to get(...)
ComFreek
@ComFreek
Other question: given a list of endpoints, can I automatically pretty-print it somehow? Such that the user gets a list of GET /post/list, POST /post/edit
Ryan Plessner
@rpless
for the first I example I tend to use fold. opt.fold[Output[String]](BadRequest(???))(_ => Ok("test")) note you do have provide the type parameter to the fold
as for the pretty-printing there as a toString that kinda does this, but you would have fiddle with the output to get the format you want
ComFreek
@ComFreek
@rpless Thanks. For the prettyprinting of endpoints, in my case I get
"(GET /help :+: (POST /archive :: build-light :+: (POST /archive :: build :+: (POST /fact :: add :: body :+: (GET /fact :: list :+: (GET /scroll :: list :+: (POST /scroll :: apply :: body :+: GET /debug :: situationtheory :: print)))))))"
which is not very helpful
even the parentheses look strangely unbalanced
e.g. GET /help is a single endpoint
ComFreek
@ComFreek
--> now posted on Finagle mailing list: https://groups.google.com/g/finaglers/c/LM5KzvSRpcI
Ryan Plessner
@rpless
the parens on that print out seem correct. basically every :+: introduces a set of parens so the endpoints wind up being fairly nested
re: your question in Finaglers auto generating developer docs isn't something that is supported at the moment. its a hard problem that we haven't solved. its one of the oldest issues on the repo finagle/finch#73
zanpakuto
@zanpakuto

I'm using finchx 0.32.1. I wrote below code, but unable to understand the reason for compilation error : "Cannot resolve overloaded method"

Can anyone please help me understand? Appreciate the help.

private val greetByName : Endpoint[IO, Json] = get(path("hello") :: paramOption("name")) = {
  Ok("Hello".asJson)
}
Ryan Plessner
@rpless
Hi @zanpakuto. I think the issue is that you are using paramOption which means the mapper is going to want an argument to the function you are using for mapping. something like this might be what you are looking for:
  private val greetByName: Endpoint[IO, Json] = get(path("hello") :: paramOption("name"))({ name: Option[String] =>
    Ok("Hello".asJson)
  })
zanpakuto
@zanpakuto
@rpless , thank you. The build is fine now.
Andrew Roberts
@aroberts
I have a POST endpoint consuming jsonBody and decoding via Circe, and I don’t seem to be able to catch the decoding error if it occurs- I want to be able to return a 400 response when bad json is submitted, but the circe DecodingFailure is wrapped in a finch-private CirceError case class. Is there a better approach to achieve this end?
Ryan Plessner
@rpless
@aroberts you should be able to access the Circe error even if its wrapped in Finch's private class. getCause should give you access to the underlying Circe error
Andrew Roberts
@aroberts
oh, interesting. I’m used to declarations shaped like class CirceError(cause: Error) extends Exception(cause) with NoStackTrace. My assumption was that CirceError.cause shadowed Exception.cause, but didn’t actually override it
Daave
@Daave_gitlab
Is there a way to get all params from a application/x-www-form-urlencoded in a Map
In play I can do it like so
def formHandler: Action[Map[String, Seq[String]]] = Action.async(parse.formUrlEncoded)
I can use param but I need to get all the params and they can be dynamic
Is there a way to do this?
Sergey Kolbasov
@sergeykolbasov
hmm, I think you need your own endpoint that is going to extract it for you. You could use something like root.map(request => request.getParams()) to get the Endpoint[F, List[Entry[String, String]]
Duncan Hills Coffee Company
@DuncanHills
can someone publish 0.32.1 to maven central?
0.31 is the latest version there...
kinda strange since that release was in march
ComFreek
@ComFreek
I copied the exception encoder from the user guide: https://finagle.github.io/finch/user-guide.html#errors
But it apparently doesn't take effect, I still get 500 internal server errors with empty body upon exceptions
Where do I have to define it?
ComFreek
@ComFreek
image.png
e.g. in this code (please ignore IntelliJ's broken graying), on runtime I get an exception and the println line is not even reached
ComFreek
@ComFreek
Not even this works:
import io.finch._
import cats.effect.IO
import com.twitter.finagle.Http
import com.twitter.io.Buf
import com.twitter.util.Await

object Test extends App with Endpoint.Module[IO] {
  implicit val encodeException: Encode.Text[Exception] =
    Encode.text((_, cs) => Buf.ByteArray.Owned("ERR!".getBytes(cs.name)))

  val api: Endpoint[IO, String] = get("hello") {
    throw new Exception("test")
    Ok("Hello, World!")
  }
  Await.ready(Http.server.serve(":8080", api.toServiceAs[Text.Plain]))
}
http://127.0.0.1:8080/hello does not output ERR! in the browser