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
megri
@megri
Actually there's an object in the finch-circe package which should solve this: https://github.com/finagle/finch/blob/master/circe/src/main/scala/io/finch/circe/package.scala#L12-L16
Dino Fancellu
@fancellu

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

e.g.

  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?

Thanks

Dino Fancellu
@fancellu

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

https://gist.github.com/fancellu/b145ed3a0a27c6a1c414c0d485a44d37

Dermot Haughey
@hderms
anyone know how I can test a finch endpoint in concert with a finagle filter in tests?
is that possible?
Sergey Kolbasov
@sergeykolbasov
@hderms you would need to convert endpoint to service, apply this service to filter and then send a Request in
Dermot Haughey
@hderms
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
@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