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

Document x-www-form-urlencoded for Java API #331

Closed
relgames opened this issue Sep 19, 2016 · 5 comments
Closed

Document x-www-form-urlencoded for Java API #331

relgames opened this issue Sep 19, 2016 · 5 comments
Labels
help wanted Identifies issues that the core team will likely not have time to work on small t:docs Issues related to the documentation t:java Issues related to the Java DSL

Comments

@relgames
Copy link

relgames commented Sep 19, 2016

Akka HTTP Java documentation does not have much examples on form requests.
One of examples which is missing is x-www-form-urlencoded used in POST requests.

Sample code which can be used as an example for both server and client form handling:

public class Test1 extends JUnitRouteTest {
    private static final Logger log = LoggerFactory.getLogger(Test1.class);

    private static class Test1Route extends AllDirectives {
        public Route createRoute() {
            return post(() ->
                formFieldMap(form -> {
                    log.info("Got form {}", form);
                    return complete("OK");
                })
            );
        }
    }

    private final TestRoute appRoute = testRoute(new Test1Route().createRoute());

    @Test
    public void testAccessControl() {
        RequestEntity requestEntity = FormData.create(
            Pair.apply("key1", "value2"),
            Pair.apply("key2", "value2")
        ).toEntity();

        appRoute.run(HttpRequest.POST("/").withEntity(requestEntity))
            .assertEntity("OK");

    }

}

From https://gitter.im/akka/akka?at=57dfd8f1c3e7045a305fac0e

@jrudolph jrudolph added help wanted Identifies issues that the core team will likely not have time to work on t:docs Issues related to the documentation 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted small t:java Issues related to the Java DSL labels Sep 19, 2016
@jrudolph jrudolph added this to the 2.4.11 milestone Sep 19, 2016
@jrudolph
Copy link
Member

Thanks, @relgames, that's a good suggestion, thanks for extracting it from the chat. Once we've finished the documentation migration, this may be a nice thing for a community contribution.

@jrudolph jrudolph modified the milestones: 2.4.11, 3.0.0 Oct 17, 2016
@ktoso ktoso modified the milestones: backlog, FIRST_STABLE Oct 26, 2016
@jlprat
Copy link
Member

jlprat commented Nov 15, 2016

Isn't this already covered now? I can see a similar example here: http://doc.akka.io/docs/akka-http/current/java/http/routing-dsl/directives/form-field-directives/formFieldMap.html

Or is this issue referring to add it somewhere else?

@relgames
Copy link
Author

relgames commented Nov 15, 2016

Indeed it is in DSL section, I did not look here as I was looking for examples of POST request using Http client. I was looking for x-www-form-urlencoded and it was not mentioned anywhere in the doc.

I think adding x-www-form-urlencoded to http://doc.akka.io/docs/akka-http/current/java/http/routing-dsl/directives/form-field-directives/formFieldMap.html should be enough.

@ktoso
Copy link
Member

ktoso commented Nov 15, 2016

Sounds good 👍 Awaiting PR 😀

@jlprat
Copy link
Member

jlprat commented Nov 16, 2016

I could do it later today. I think it's good if it's added in http://doc.akka.io/docs/akka-http/current/java/http/routing-dsl/directives/by-trait.html (when the FormFieldDirectives are explained) and in each FormFieldDirective.
I'll do it for both Java and Scala (for Scala only where it makes sense, as I think it already has quite more info about x-www-form-urlencoded

@ktoso ktoso closed this as completed Nov 17, 2016
@ktoso ktoso removed the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Nov 17, 2016
@ktoso ktoso modified the milestones: 10.0.0 "first stable", backlog Nov 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Identifies issues that the core team will likely not have time to work on small t:docs Issues related to the documentation t:java Issues related to the Java DSL
Projects
None yet
Development

No branches or pull requests

4 participants