Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 20 18:59
    julienrf commented #1033
  • May 20 18:47
    codecov[bot] commented #1033
  • May 20 17:55
    codecov[bot] commented #1033
  • May 20 17:54
    lolgab synchronize #1033
  • May 20 17:49
    lolgab edited #1033
  • May 20 16:25
    codecov[bot] commented #1036
  • May 20 16:16
    scala-steward opened #1036
  • May 20 06:56
    julienrf closed #1035
  • May 20 04:32
    scala-steward opened #1035
  • May 13 10:31
    codecov[bot] commented #1034
  • May 13 10:19
    scala-steward opened #1034
  • May 02 13:54
    codecov[bot] commented #1033
  • May 02 13:27
    lolgab edited #1033
  • May 02 13:24
    codecov[bot] commented #1033
  • May 02 13:24
    lolgab synchronize #1033
  • May 02 13:22
    codecov[bot] commented #1033
  • May 02 13:22
    lolgab synchronize #1033
  • May 02 12:03
    codecov[bot] commented #1033
  • May 02 11:45
    lolgab commented #1033
  • May 02 11:44
    lolgab ready_for_review #1033
Dominic Egger
@GrafBlutwurst
I noticed something recently when looking at our logs. Is it just me using it wrong or does handleClientErrors suffer from the fact that you don't know what route actually failed. e.g. in POST /foo/bar/ the body failed to decode, you won't know it was on POST /foo/bar
Julien Richard-Foy
@julienrf
@GrafBlutwurst Which server do you use?
Dominic Egger
@GrafBlutwurst
http4s
but isn't it an issue of the algebra because handleClientErrors only gets an instance of Invalid ?
Julien Richard-Foy
@julienrf
This method is not defined in the algebra, only in the http4s server interpreter
But I agree that it seems impossible to know the route that failed from there
(ftr, the equivalent method in the akka-http interpreter does provide a way to retrieve the underlying route)
So, in the case of the http4s server, I agree that we should change the signature of handleClientErrors to receive more information about the underlying request
Dominic Egger
@GrafBlutwurst
ahh yeah i see it's on the http4s package. what would you thinkg the signature should be? then I can maybe do an MR soon :tm: (whenever the ticket for the logging enhancement lands in my sprint)
Julien Richard-Foy
@julienrf
I guess we want to add a Request parameter to the method handleClientErrors?
Dominic Egger
@GrafBlutwurst
hmm I suppose that's the way to go yeah. that makes sense. I'll have a sprint planning today and will lobby for me to grab that ticket so I can do an MR soon
Julien Richard-Foy
@julienrf
Thanks!
Dominic Egger
@GrafBlutwurst
fun fact. -XX:+CMSClassUnloadingEnabled in .jvmopts breaks sbt 1.4.7 with my java version since it seems to be an unknown argument
that being Java 15.0.1 do we need that flag?
Julien Richard-Foy
@julienrf
To be honest I don’t remember why it was added. Just try without it.
Dominic Egger
@GrafBlutwurst
endpoints4s/endpoints4s#755 done. yeah i threw out the VM arg. I think it's a common flag for SBT speedup but it works just fine without it.
Dominic Egger
@GrafBlutwurst
I killed bincompat with the signature change though. sorry :|
Julien Richard-Foy
@julienrf
It’s OK, we can bump the major version of the http4s interpreter, unless this is a problem?
Dominic Egger
@GrafBlutwurst
not for me certainly. I adjusted the MR accordingly
Dominic Egger
@GrafBlutwurst
re #755 should I do the same for serverErrors? or would you prefer a seperate MR?
3 replies
Dominic Egger
@GrafBlutwurst
Is there a good way to add the capability of tapping and transforming on an algbera? e.g. I want to log requests and responses, or add authentication? sure i could do that on http4s directly (except that I don't have control over the log format there).

The way i did that right now is by having an intermediate trait with

  protected def authenticatedRequest[UrlP, BodyP, Out](
    method: Method,
    url: Url[UrlP],
    entity: RequestEntity[BodyP]
  )(implicit
    tuplerUB: Tupler.Aux[UrlP, BodyP, Out]
  ): Request[ApiEndpoints.AuthenticatedMessage[Out]]

and that works fine for requests. but one of the issues of response logging is that the process of encoding a response is not effectful

Julien Richard-Foy
@julienrf
@GrafBlutwurst Most of the types support the xmap operation for transforming them. However, xmap takes two pure functions only, not effectful functions.
Dominic Egger
@GrafBlutwurst
Yeah that's what makes it tricky. some functionallity that we currently treat as pure would become effectful
I am even considering operating on the algebra itself and changing the way the implementedByEffect works to accomodate this
Julien Richard-Foy
@julienrf
So, I think the only way to go is to do like you did. Define your own methods that wrap the existing algebra, and that do their side-effects. But this might need some changes in how the http4s interpreter is defined, since not all types can be interpreter with effectful computations, as you noticed…
Dominic Egger
@GrafBlutwurst
but it'd be very cumbersome I think
maybe a new abstract type member that captures the effect on encoding?
then what I want would be much easier, overwrite that, add effectful logging and i should be done. might need some annoying machinery though to make this work though
Adriaan Groenenboom
@agboom
Don't know if this is related, but are there ways in the current algebra to compose different endpoints? For example, we have multiple endpoints that add functionality to an endpoint, such as authenticatedEndpoint[A, B]: Endpoint[A, Either[AuthError], B], endpointWithError[A, B]: Endpoint[A, Either[ClientError, B]] and versionedEndpoint[A, B](version: ApiVersion): Endpoint[A, B]. Because the Endpoint type is abstract, I cannot find a way to compose these like (pseudo-code): authenticateEndpoint(endpointWithError(versionedEndpoint(...))).
One way we thought of is to instantiate and Endpoint to a class like Endpoints(request: A, response: B, url: String,...) and then "rewrite" these in the interpreters to the corresponding instances (e.g. Route for Akka HTTP server or A => Future[B] for client). But I have a feeling this would involve a pretty fundamental change to the algebras so I'm certainly open to other ideas.
23 replies
This message was deleted
Adriaan Groenenboom
@agboom
What is exactly the use of def uri in the Akka HTTP interpreter? It doesn't seem to be used in any code, except via-via in a single line in one test. Could it be possible that the function is not needed? https://github.com/endpoints4s/endpoints4s/blob/master/akka-http/server/src/main/scala/endpoints4s/akkahttp/server/Endpoints.scala#L50
5 replies
Domantas Petrauskas
@ptrdom
Hi, I'm trying to figure out if Scala.js frontend + Akka-HTTP backend could use chunked JSON entities for both requests and responses. Seems like chunked JSON entities aren't implemented under endpoints.xhr, so it is not supported, right?
Julien Richard-Foy
@julienrf
@ptrdom Hello, you’re right ChunkedEntities is not supported by endpoints.xhr. I don’t remember why I didn’t include it, to be honest. I also remember that I created #287 when I was working on it, so maybe I faced some limitations when trying to implement ChunkedEntities in the xhr interpreter.
Domantas Petrauskas
@ptrdom
@julienrf Thank you for the reply. I am really interested in having a capability of bidirectional streaming in API. grpc-web should eventually support this, but there is no clear timeline for client-side streaming support, and protobuf model does seem unnecessarily limiting for traditional web API, compared to JSON. It would be an interesting endeavor to implement endpoints4s/endpoints4s#287, maybe I could give it a shot.
Julien Richard-Foy
@julienrf
@ptrdom That would be a great contribution, although it might require some significant work! By the way, I’ve just found this old attempt at implementing an xhr interpreter for streaming: https://github.com/endpoints4s/endpoints4s/compare/streaming-support#diff-fe8014ca568bf3fc852541330ae13649cf8d4e298abea4ce777f73ddeabd33e2.
I don’t fully remember if eventually I didn’t include it in my final work on streaming because it was not working, or because I didn’t have the resources to finalize the implementations
See also the PR that introduced streaming support, where I give some implementation details: endpoints4s/endpoints4s#465
Domantas Petrauskas
@ptrdom
@julienrf Neat, I can also see that you attempted implementing WebSocket endpoints. I'll check these references out before I start, hoping this will result in an actual contribution.
Rohan Sircar
@rohan-sircar
does the http4s server interpreter also not supprt ChunkedEntities/ChunkedJsonEntities?
Simon Parten
@Quafadas
Is endpoints4s compatible with https://github.com/com-lihaoyi/cask ?
Simon Parten
@Quafadas
Conclusion: no. I'm going to assume adding it is also a non trivial task!
Mark de Jong
@Fristi
Hiya, I added sttp3 support in a PR
Coverage dropped by 0,07% :roller_coaster:
Build failed due that reason :see_no_evil:
Julien Richard-Foy
@julienrf
Hello! I’ve just released endpoints4s 1.4.0 with your latest contributions! https://github.com/endpoints4s/endpoints4s/releases/tag/v1.4.0
Dominic Egger
@GrafBlutwurst
Thanks for the release Julien!
Adriaan Groenenboom
@agboom
Great news, thanks for the release and all the effort!
Milos Nedeljkovic
@minedeljkovic

It seems that format is not generated for parameters in openapi docs , but it is for request and response body content.
For example, this definition

  val foo: Endpoint[(Long, Long, Long), Long] =
    endpoint(
      request = put(
        path / "foo" / segment[Long]("id") /? qs[Long]("long"),
        jsonRequest[Long]
      ),
      response = ok(jsonResponse[Long])
    )

generates parameters without format

  "parameters": [
    {
      "name": "id",
      "in": "path",
      "schema": {
        "type": "integer"
      },
      "required": true
    },
    {
      "name": "long",
      "in": "query",
      "schema": {
        "type": "integer"
      },
      "required": true
    }
  ],

but request and response body content with format

  "content": {
    "application/json": {
      "schema": {
        "type": "integer",
        "format": "int64"
      }
    }
  }

Is this intended?

Julien Richard-Foy
@julienrf
Good catch @minedeljkovic, this is an issue that should be fixed, IMHO. Do you mind filing an issue description in the repository?