Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 14 04:53
    scala-steward opened #840
  • Jun 13 18:22
    mleclercq commented #671
  • Jun 13 18:13
    julienrf assigned #839
  • Jun 13 18:11
    codecov[bot] commented #839
  • Jun 13 18:03
    mleclercq commented #834
  • Jun 13 18:03
    mleclercq opened #839
  • Jun 13 06:54
    julienrf commented #834
  • Jun 12 15:17
    mleclercq commented #834
  • Jun 12 00:24
    mleclercq commented #834
  • Jun 10 14:26
    codecov[bot] commented #838
  • Jun 10 14:19
    scala-steward opened #838
  • Jun 10 09:16
    codecov[bot] commented #837
  • Jun 09 06:17
    julienrf commented #834
  • Jun 08 23:05
    mleclercq commented #834
  • Jun 08 16:33
    scala-steward opened #837
  • Jun 08 14:34
    codecov[bot] commented #836
  • Jun 08 14:26
    scala-steward closed #821
  • Jun 08 14:26
    scala-steward commented #821
  • Jun 08 14:26
    scala-steward opened #836
  • Jun 08 10:16
    codecov[bot] commented #826
Rustam Sultanov
@RustamSultanov
sttp have support scala.js backend but now endpoints4s support only jvm back endpoints4s/endpoints4s#571
Julien Richard-Foy
@julienrf
@sloshy We should change the API and add a parameter for the base URL in the xhr Scala.js client
Julien Richard-Foy
@julienrf
@sloshy Thanks for the investigation about Content-Length. My understanding is that we could set this header, but this should not be required for the http4s backend to work correctly.
Ryan Peters
@sloshy
@julienrf Right, it was partially a bug in the http4s Ember backend where a bad default was chosen. I think the bug should be fixed now, or at least on trunk. Now, I'm not exactly super HTTP-fluent so you'll have to excuse this stupid question: would setting the Content-Length header by default where possible be an undesirable change? Is there a reason it is not implemented now VS it just "not being there"? I'm wondering if it's something I could contribute, or if it's a matter of opinion
Julien Richard-Foy
@julienrf
@sloshy Such a contribution would be very welcome :) I see no reason to not set the Content-Length header, if we can. The fact that it is not currently set is an oversight. I think the Play server interpreter does set it, actually. I don’t know for the others.
Mark
@Fristi
@julienrf I've bumped sttp to 2.2.9 (latest stable 2.x release, I think 3.x is around the corner as well, yet I would like this one as I'm using it for projects atm) endpoints4s/endpoints4s#675
Julien Richard-Foy
@julienrf
:pray: thanks!
Mark
@Fristi
When would you able to release the sttp 2.0 module?
Julien Richard-Foy
@julienrf
@Fristi I wanted to make sure the support of optional fields with default values was well designed. I stumbled upon this problem: https://github.com/endpoints4s/endpoints4s/issues/660#issuecomment-722464040
@harpocrates did you make some progress on the support of optional query string parameters with default values?
1 reply
Julien Richard-Foy
@julienrf
@/all I’ve just released endpoints4s-1.2.0 :) See the release notes here: https://github.com/endpoints4s/endpoints4s/releases/tag/v1.2.0
Mark
@Fristi
Thanks! :)
Leif Warner
@LeifW
I've got a route that naturally wants to return a Option[Either[Future]] - it can return 404 or 400 or 200. - Though the implementedByAsync wants the Future to be on the outside.
Is there anything to be done for that? Seems I'll have to do some weird type stuff to swap those around. Thinking about using EitherT[OptionT[Future]] from cats...
Julien Richard-Foy
@julienrf
@LeifW maybe you’ll find an answer here: https://www.youtube.com/watch?v=yEYPf44rS2U
Leif Warner
@LeifW
I guess doing traverse + traverse works.
For some reason sequence on the result wasn't working at all, but traverse does work.
Leif Warner
@LeifW
It seems more common to be to have the Either on the outside - because I do some validation before deciding whether to immediately return 400 or kick off the Future IO action... but traverse works.
Georgi Krastev
@joroKr21
In that case you can do the traverse already in the validation step :thumbsup:
Leif Warner
@LeifW
If I have a lot of different response codes I might want to return, e.g. 200 or 201 or 204 or 400 - does that mean I just nest a bunch of Eithers?
Alec Theriault
@harpocrates
If you've got a lot of possible response codes, you can xmapover the ResponseEntity to turn your nested Either's into some more palatable sealed trait that better fits your domain. That way, the Either stuff shows up only in the body of the endpoint definition and the type of the whole endpoint is in terms of your domain.
Dominic Egger
@GrafBlutwurst
out of curiosity why is QueryString an invariant partial functor? when is there a need to translate from decoded params to query string?
Julien Richard-Foy
@julienrf
@GrafBlutwurst Client interpreters encode params into a query string
Dominic Egger
@GrafBlutwurst
ahhh right makes sense. thanks!
Dominic Egger
@GrafBlutwurst
how does the JsonEntitiesFromEncodersAndDecoders differ from JsonEntitiesFromCodec http4s seems to have the latter but an endpoint serving OpenApi seems to use the former?
Julien Richard-Foy
@julienrf
FromEncodersAndDecoders only requires an Encoder to be available, whereas FromCodec requires both an Encoder and a Decoder. In the case of OpenApi, we only have an Encoder so far, that’s why we still have these JsonEntitiesFromEncodersAndDecoders traits
Dominic Egger
@GrafBlutwurst
ahhh then the AndDecoders bit is slightly confusing i suppose. but that makes a lot of sense. but the algebra is not available for http4s server it seems? or is my code discovering just broken?
hmm I think i need a flavour of jsonResponse that does not require a Codec in that case
Julien Richard-Foy
@julienrf
indeed, we miss the http4s version of the interpreter JsonEntitiesFromEncodersAndDecoders
(it should be easy to add, though)
Leif Warner
@LeifW
Is there a way of turning Paths into nice strings - to refer to from the documentation of other routes?
Julien Richard-Foy
@julienrf
@LeifW I think all the client interpreters should be able to do that. The play-server and xhr-client interpreters have dedicated methods for that. Which interpreter do you use?
caeus
@caeus
Quick question. Does Endpoints4s support xxx-urlencoded-form content type? if so, how?
Julien Richard-Foy
@julienrf
@caeus There is no out-of-the-box support but it would be easy to add even as a third-party extension (without changing the library itself)
Julien Richard-Foy
@julienrf
Hello @/all, I have added an “Adopters” section to the README, I would appreciate if you could give me a few organization names I can add to the list :smile: https://github.com/endpoints4s/endpoints4s/blob/master/README.md#adopters
Dominic Egger
@GrafBlutwurst
1 reply
Leif Warner
@LeifW
@julienrf Using the akka http interpreter.
1 reply
In the routes, I've been using Either and having it Left(Invalid(...)) on the failure case - noticing that Invalid's the failure case of Validated... wondering if I should be having the routes return Validated instead of Either?
2 replies
Julien Richard-Foy
@julienrf
@LeifW Actually, I just realized that you want to be able to do that in the documentation, not necessarily in the server
So, this is something we could add to the openapi interpreter maybe, and all the server interpreters would benefit from it
I’ve just opened #728 to implement it in the Akka HTTP server interpreter, though
Leif Warner
@LeifW
Nice, thanks!
In the error handlers, you have access to the Throwable... I'm wondering if there's a spot that has access to both that Throwable, and the request (at least the name of the endpoint that was called)?
I'd like to log unexpected Throwables, but was thinking it'd also be nice to log the request that lead to that exception being thrown...
Julien Richard-Foy
@julienrf
@LeifW handleServerError returns a StandardRoute, so you can extract request information in the returned route.
Julien Richard-Foy
@julienrf
Hey @/all, I have just cut a new release: https://github.com/endpoints4s/endpoints4s/releases/tag/v1.3.0 thank you all for your contributions!
Adriaan Groenenboom
@agboom
Hi, does anyone know if it is possible to define an endpoint with a url that ends with a slash (or optional slash)? I tried the following but it still gave a 404 on localhost/foo/ (but not on localhost/foo):
endpoint(
  method = Get,
  url = path / segment[String]() / "",
  response = textResponse,
)
Adriaan Groenenboom
@agboom
(this is with the Akka HTTP backend btw)
Julien Richard-Foy
@julienrf

@agboom I think this use case is not covered at the moment. You may want to introduce something like the following:

def trailingSlash[A](path: Path[A]): Path[A]

Which you could use as follows:

endpoint(
 method = Get,
  url = trailingSlash(path / segment[String]()),
  response = textResponse
)
And you would have to figure out the implementations for server, client, and openapi interpreters, according to your usage
Adriaan Groenenboom
@agboom
Thanks for the pointer @julienrf, I was indeed thinking the same. I'll try to implement it and open a PR if I succeed
Julien Richard-Foy
@julienrf
That would be great, thanks!
Let me know if you need more help