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

Add routes#serve method #2829

Merged
merged 7 commits into from
May 16, 2024
Merged

Conversation

GrigoriiBerezin
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented May 7, 2024

CLA assistant check
All committers have signed the CLA.

@@ -282,6 +282,10 @@ object Routes extends RoutesCompanionVersionSpecific {
def singleton[Env, Err](h: Handler[Env, Err, (Path, Request), Response])(implicit trace: Trace): Routes[Env, Err] =
Routes(Route.route(RoutePattern.any)(h))

implicit class RouteOps[-Env, +Err <: Response](val routes: Routes[Env, Err]) extends AnyVal {
def serve: URIO[Env with Server, Int] = Server.install(routes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the focus here is on usability, I think this should be calling Server.serve instead, so users don't have to call ZIO.never afterwards. I believe this was what the issue was aiming for as well

Copy link
Contributor Author

@GrigoriiBerezin GrigoriiBerezin May 7, 2024

Choose a reason for hiding this comment

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

Oh, I get it, my bad, thx for notice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -282,6 +282,10 @@ object Routes extends RoutesCompanionVersionSpecific {
def singleton[Env, Err](h: Handler[Env, Err, (Path, Request), Response])(implicit trace: Trace): Routes[Env, Err] =
Routes(Route.route(RoutePattern.any)(h))

implicit class RouteOps[-Env, +Err <: Response](val routes: Routes[Env, Err]) extends AnyVal {
Copy link
Collaborator

Choose a reason for hiding this comment

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

By the way sorry if this a stupid question, but do we need the implicit class? Isn't possible to have this as a method directly implemented on Routes instead or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just wanted to have implementations of server far from route implementation, mb I'm wrong

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a valid point. @khajavi @987Nabil any thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

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

This seems to be valid, but I am uncertain if it provides any significant advantages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I move it into implementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

No implicit. Just a method on routes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done it, but now it's failing with handshake test for some reason

@GrigoriiBerezin GrigoriiBerezin force-pushed the add_routes_serve_method branch 6 times, most recently from c6dadc4 to 26f546e Compare May 12, 2024 16:49
Copy link
Member

@jdegoes jdegoes left a comment

Choose a reason for hiding this comment

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

Good to merge when CI is passing!

@GrigoriiBerezin GrigoriiBerezin force-pushed the add_routes_serve_method branch from 4d990c8 to 03762b7 Compare May 12, 2024 18:50
Copy link
Member

@jdegoes jdegoes left a comment

Choose a reason for hiding this comment

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

Good to merge when CI passing!

@GrigoriiBerezin
Copy link
Contributor Author

Finally have fixed all issues

@987Nabil 987Nabil merged commit 8510bfb into zio:main May 16, 2024
33 checks passed
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.

6 participants