reactor / reactor-netty

TCP/HTTP/UDP/QUIC client/server with Reactor over Netty
https://projectreactor.io
Apache License 2.0
2.58k stars 647 forks source link

HttpServerRoutes should support query parameters #68

Open lucasponce opened 7 years ago

lucasponce commented 7 years ago

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

odravison commented 3 years ago

This feature was implemented?

violetagg commented 3 years ago

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

odravison commented 3 years ago

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?

violetagg commented 3 years ago

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

violetagg commented 3 years ago

@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 commented 3 years ago

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

coditori commented 2 years ago

From 2017 to 2022 and still nothing :|