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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormData and marshalling, easier/possible to use #18665

Closed
ktoso opened this issue Oct 7, 2015 · 10 comments
Closed

FormData and marshalling, easier/possible to use #18665

ktoso opened this issue Oct 7, 2015 · 10 comments
Assignees
Milestone

Comments

@ktoso
Copy link
Member

ktoso commented Oct 7, 2015

Let's say I'm in Java and want to test a route which deals with FormData (I actually really do 馃槈), I'd want to say:

    final HttpRequest request =
      HttpRequest
        .POST("/") // the below method does not exist (FormData also does not exist in javadsl)
        .withFormData(FormData.create(Pair.create("name", "Kapi"), Pair.create("age", "42")));

but can't since HttpRequest (or even HttpMessage) is not aware of FormData (i.e. the method withFormData does not exist). We also can't provide it on the type since it's in akka-http-core and we'd need marshallers, which are in akka-http (PredefinedToEntityMarshallers).

I don't have a good idea how to solve this simply...? One would have to manually call marshalling and use withEntity I guess now...? Open to other ideas (are we need a full DSL for request building for java?)

@ktoso
Copy link
Member Author

ktoso commented Oct 7, 2015

// cc @rkuhn @sirthias @jrudolph

@ktoso ktoso added the 3 - in progress Someone is working on this ticket label Oct 7, 2015
@ktoso ktoso self-assigned this Oct 7, 2015
@ktoso ktoso added this to the http-1.1 milestone Oct 7, 2015
@ktoso ktoso changed the title FormData and marshalling, easier to use FormData and marshalling, easier/possible to use Oct 7, 2015
@ktoso
Copy link
Member Author

ktoso commented Oct 7, 2015

Maybe providing a Marshaller of FormData => Entity would be enough, in javadsl Marshallers?

@jrudolph
Copy link
Member

jrudolph commented Oct 7, 2015

In any case, withFormData isn't enough to specify the request because it could either be url encoded or multipart formdata.

@jrudolph
Copy link
Member

jrudolph commented Oct 7, 2015

On the other hand, there's also still #15674 which is somewhat of a pain to port because of all the complexity that's inside, so having a simple solution that works for forms with textual data would really be nice.

@ktoso
Copy link
Member Author

ktoso commented Oct 7, 2015

Right, that's true as well.
So what do you propose for now for Java users - should marshalling infra be called explicitly?
Then we must provide the ToEntityMarshaller for FormData in an accessible way for Java anyway.
Or am I missing some way of doing this already?

@ktoso
Copy link
Member Author

ktoso commented Oct 7, 2015

Ah right, yeah it definitely links to #15674 in some ways.

@jrudolph
Copy link
Member

jrudolph commented Oct 7, 2015

At some point I added Multipart.FormData.toEntity already, so that's already usable from Scala without needing any marshallers. I think we should also add a model.FormData.toEntity, to simplify this as well.

Having done that, it would be easy to add the helper methods to the Java side HttpMessage even if the model itself is still missing on the Java side.

@jrudolph
Copy link
Member

jrudolph commented Oct 7, 2015

@ktoso
Copy link
Member Author

ktoso commented Oct 7, 2015

Ok, so we don't feel it's against the purity of the core or sth like that ;-)
I'll give the move a shot then

Again, huge thanks for all the hints @jrudolph - it's really invaluable.

@ktoso
Copy link
Member Author

ktoso commented Oct 8, 2015

Managed to solve it by reusing the hinted at code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants