-
Notifications
You must be signed in to change notification settings - Fork 412
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
Add routes#serve method #2829
Conversation
fd14079
to
b8ac0e2
Compare
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
c6dadc4
to
26f546e
Compare
There was a problem hiding this 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!
4d990c8
to
03762b7
Compare
There was a problem hiding this 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!
Finally have fixed all issues |
No description provided.