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
#1669 for discussion only #1676
Conversation
@ctlove0523 I converted this PR to draft. |
How to code my dns with other Parsing logic |
reactor-netty-http/src/main/java/reactor/netty/http/server/HttpPredicate.java
Outdated
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerRoutes.java
Outdated
Show resolved
Hide resolved
@ctlove0523 just wanna add the general comment that the logic sounds like a filter logic where you based on the incoming request filters it or not. Though it can work for some use cases, it cannot help in scenarios where one needs to replace a handler with an equivalent one. |
reactor-netty-http/src/main/java/reactor/netty/http/server/DefaultHttpServerRoutes.java
Outdated
Show resolved
Hide resolved
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.
LGTM in general with some minor polishes
reactor-netty-http/src/main/java/reactor/netty/http/server/DefaultHttpServerRoutes.java
Outdated
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/server/HttpRouteHandlerMetadata.java
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerRoutes.java
Show resolved
Hide resolved
reactor-netty-http/src/test/java/reactor/netty/http/server/HttpServerTests.java
Show resolved
Hide resolved
Nice work. Only Problem I see is that I can only specify the route that should be removed by path/method. In my use case I have to deal with unknown services that have no knowledge of each other. Imagine the following scenario: 1.) First OSGI service is started and adds a new route with path The current solution would remove both routes (Route of OSGI service "First" and "Second"), or did I miss something? |
In one HttpServer you can add many same route,but if you not order same routes,request will match first added route.From your description you want a concept like route owner,owner can only remove routes which added by the owner,but HttpServer has't this concept. |
That's correct. But adding a duplicate route will not harm the first added route. The first registered route will work, even if you register millions of routes with the same path/predicate. Problem I see is that if you not aware of all other routes (e.g. App with Plugin Concept, OSGI ......), you can remove a existing route accidentally when you try to remove "your" route. You will remove the first (working) route and "harm" the application since a route which was previously working suddenly does not to work, although your intention was to remove just "your" route. Debugging such "suddenly disappearing" routes could be a nightmare ..... With wildcard predicate handlers it might be even worse: If you register a wildcard predicate handler, that should return a nice 404 page on every request which was not matched by a previous handler, using Don't get me wrong. I really like your work and I really appreciate all the effort you put into it. All I'm saying is that there might be uses cases where this solution might cause trouble since it's only safe to use it if you are aware of all added routes (Which might be even a problem when multiple teams work on the same project). I don't know/ can not decide if these use cases are valid and should be supported by reactor-netty, someone else has to make this decision.
You are right, but maybe it should have such concept (Returning |
@roggenbrot when add route return an object which can identity added route |
@roggenbrot Do you think that if we add something like a route identity, it will solve your use case? I do not have information for your solution but in your case it may be OSGi service name or whatever will give you the information whether or not to remove the route. |
@ctlove0523 @roggenbrot I'll postpone this for 1.0.11 so that we can clarify the comment #1676 (comment) |
@ctlove0523 @roggenbrot I'm going to commit this change. @roggenbrot We can reopen your issue if you think that #1676 (comment) may help for your use case. |
reactor-netty-http/src/main/java/reactor/netty/http/server/HttpRouteHandlerMetadata.java
Outdated
Show resolved
Hide resolved
reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServerRoutes.java
Outdated
Show resolved
Hide resolved
Ok,if there are other requirements, i will continue to this. |
Thank you all for the discussion and the PR! |
In current version,reactor netty hasn't really concept about ‘route’,we can't define route directly use code.In reactory netty,
HttpRouteHandler
is the route,when one request come in,we iterateHttpRouteHandler
list to find oneHttpRouteHandler
can handle income request,if noHttpRouteHandler
can handle request return http status code 404(mean no route). In the iterate process we usePredicate<? super HttpServerRequest>
to match request one by one,whenPredicate<? super HttpServerRequest>
return true,it means there is one route for this request,so i think in reactory nettyPredicate<? super HttpServerRequest>
is the "route".