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

http: remove unused put and delete methods #273

Merged
merged 1 commit into from
Aug 1, 2021

Conversation

pablopalacios
Copy link
Contributor

@redonkulus while refactoring the tests for the other PR, I realized that we don't use delete nor put from the http module.

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@redonkulus
Copy link
Contributor

@pablopalacios Can you explain this more? What do you mean they were not used?

@pablopalacios
Copy link
Contributor Author

pablopalacios commented Jul 29, 2021

@redonkulus Yes.

The flow in the client is something like this:

  1. Instantiate Fetchr
  2. Call a operation method in a resource fetchr.read('resource')
  3. Internally, fetchr will create a Request object (https://github.com/yahoo/fetchr/blob/master/libs/fetcher.client.js#L450)
  4. the request object has a method end that calls executeRequest (https://github.com/yahoo/fetchr/blob/master/libs/fetcher.client.js#L185)
  5. executeRequest decides if it should use POST or GET based in the operation (https://github.com/yahoo/fetchr/blob/master/libs/fetcher.client.js#L185)
  6. Based on that, we will either call http.client.get (https://github.com/yahoo/fetchr/blob/master/libs/fetcher.client.js#L295) or http.client.post (https://github.com/yahoo/fetchr/blob/master/libs/fetcher.client.js#L324)

You can check all the references for http.client (import as REST), only get and post methods are called in the whole codebase. So even though I would expect that update and delete methods would use PUT and DELETE, currently they will use POST.

If caching was not an important thing, I would make all the requests using POST and pass all the stuff in the request body.

@redonkulus
Copy link
Contributor

Good find, this is interesting. Do we not see the need for put and delete from the client code? I guess it's never come up before, so it's probably safe to remove.

@pablopalacios
Copy link
Contributor Author

pablopalacios commented Jul 29, 2021

I see no reason for using it. In the end the communication between client and server is a "closed" fetchr protocol: client fetchr talks to server fetchr middleware. As I said, we could even do everything using only POST for the sake of making things simpler. But this would harm caching or make it very difficult to do.

@redonkulus redonkulus merged commit ccd3efb into yahoo:master Aug 1, 2021
@redonkulus
Copy link
Contributor

pablopalacios added a commit to pablopalacios/fetchr that referenced this pull request Aug 31, 2021
@pablopalacios pablopalacios deleted the remove-unused-methods branch July 23, 2024 07:43
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

Successfully merging this pull request may close these issues.

2 participants