reactor-netty icon indicating copy to clipboard operation
reactor-netty copied to clipboard

HttpServerRoutes should support query parameters

Open lucasponce opened this issue 8 years ago • 9 comments

Defining a route [1] like

        context = HttpServer.create(8556)
                .newRouter(r -> r
                        .get("/hawkular/alerts", (req, resp) -> {
                            return resp.sendString(Mono.just("Get alerts"));
                        })
                        .route(req -> true, (req, resp) -> {
                            QueryStringDecoder query = new QueryStringDecoder(req.uri());
                            System.out.printf("route: %s %s\n", query.path(), query.parameters());
                            return resp.send();
                        })
                ).block();

get should accept query parameters in some way.

For example, a call like

curl http://localhost:8556/hawkular/alerts?query=AA

should be handled by the "get" route and not the second "route" one, as there is match in the path.

[1] https://github.com/reactor/reactor-netty/blob/master/src/main/java/reactor/ipc/netty/http/server/HttpServerRoutes.java#L174

P.S.: Testing this on 3.0.5.RELEASE version

lucasponce avatar Apr 06 '17 11:04 lucasponce

This feature was implemented?

odravison avatar Nov 11 '20 14:11 odravison

@odravison No it is not. Are you interested in providing a PR?

violetagg avatar Nov 11 '20 14:11 violetagg

Maybe I do this soon. Just let me get a free time to do so.

Do you know if this feature (query parameters) was implemented on HttpClient module?

odravison avatar Nov 11 '20 14:11 odravison

@odravison There is similar feature request for query params on the client https://github.com/reactor/reactor-netty/issues/753

violetagg avatar Nov 11 '20 14:11 violetagg

@odravison Also can you clarify the use case? Is it for routing? If yes can't you use the current API for custom predicates for routing?

violetagg avatar Nov 11 '20 14:11 violetagg

Note: When implementing this feature, we need to discuss also non URL-encode query parameters - #1561

violetagg avatar Mar 29 '21 17:03 violetagg

From 2017 to 2022 and still nothing :|

coditori avatar Mar 25 '22 11:03 coditori