Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize some zio.http.endpoint.Endpoint code #3213

Merged
merged 8 commits into from
Dec 24, 2024
Merged

Conversation

guizmaii
Copy link
Member

@guizmaii guizmaii commented Nov 19, 2024

Replace the NonEmptyChunk.formChunk(...).getOrElse(...) with chunk.nonEmptyOrElse(...)(...)
Removes an Option allocation

@guizmaii guizmaii self-assigned this Nov 19, 2024
@987Nabil
Copy link
Contributor

Please reopen when it builds

@987Nabil 987Nabil closed this Nov 25, 2024
@guizmaii guizmaii reopened this Nov 26, 2024
@guizmaii guizmaii force-pushed the optimise/handlers branch 2 times, most recently from a47f508 to e1f0a79 Compare November 26, 2024 07:31
@guizmaii
Copy link
Member Author

@987Nabil Should be good now :)

Replace the `NonEmptyChunk.formChunk(...).getOrElse(...)` with `chunk.nonEmptyOrElse(...)(...)`
@@ -55,7 +55,8 @@ final case class Endpoint[PathInput, Input, Err, Output, Auth <: AuthType](
codecError: HttpCodec[HttpCodecType.ResponseType, HttpCodecError],
documentation: Doc,
authType: Auth,
) { self =>
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated and unnecessary format change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

authCodec(auth1).orElseEither(authCodec(auth2))(Alternator.leftRightEqual[Unit])
}
def authCodec(authType: AuthType): HttpCodec[HttpCodecType.RequestType, Unit] =
authType match {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated and unnecessary format change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

handlers: Chunk[(Handler[Env, Nothing, Request, Response], HttpCodec.Fallback.Condition)],
): NonEmptyChunk[(Handler[Env, Response, Request, Response], HttpCodec.Fallback.Condition)] = {
def noFound: NonEmptyChunk[(Handler[Env, Response, Request, Response], HttpCodec.Fallback.Condition)] =
NonEmptyChunk(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we make this a constant?

@987Nabil 987Nabil enabled auto-merge (squash) December 24, 2024 14:51
@987Nabil 987Nabil merged commit 079f3d8 into main Dec 24, 2024
67 checks passed
@987Nabil 987Nabil deleted the optimise/handlers branch December 24, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants