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

Convenience features for NextcloudRequest.Builder #413

Open
stefan-niedermann opened this issue Nov 17, 2021 · 0 comments
Open

Convenience features for NextcloudRequest.Builder #413

stefan-niedermann opened this issue Nov 17, 2021 · 0 comments

Comments

@stefan-niedermann
Copy link
Member

Issue

The following setup for a NextcloudRequest is quite verbose:

final var parameters = Collections.singleton(new QueryParam("foo", "bar"));
final var nextcloudRequest = new NextcloudRequest.Builder()
    .setMethod("GET")
    .setParameter(parameters)
    .setUrl("/endpoint")
    .build();

Especially for beginners, we should try to minimize the necessary boilerplate code to perform an actual request.

Proposal

Automatically parse QueryParams from the given URL

We could parse the QueryParams from the given URL and add them to our Collection (just as if .setParameter() would have been called). A working sample implementation (in Kotlin) is already in the nextcloud-commons library available.

final var nextcloudRequest = new NextcloudRequest.Builder()
    .setMethod("GET")
    .setParameter(parameters)
    .setUrl("/endpoint?foo=bar")
    .build();

Default method property to GET

It is the most often used HTTP verb and a natural choice to be preset (of course with keeping the possibility to override it):

final var parameters = Collections.singleton(new QueryParam("foo", "bar"));
final var nextcloudRequest = new NextcloudRequest.Builder()
    .setParameter(parameters)
    .setUrl("/endpoint")
    .build();

Looking forward to some opinions 🙂
PS.: This issue has been split out of #266

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

No branches or pull requests

1 participant