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

Fix typo POST -> PUT #4628

Merged
merged 1 commit into from
May 31, 2023
Merged

Fix typo POST -> PUT #4628

merged 1 commit into from
May 31, 2023

Conversation

ecerulm
Copy link
Contributor

@ecerulm ecerulm commented May 31, 2023

Overview

The documentation at 1.5.14 says PUT but then the example says POST. This PR fixes so that both says PUT.

image

I have tried myself and it seem that both PUT and POST can actually be used, but I assuming that PUT is the preferred.

*PUT:

curl -v -n  -T  functioninput.txt  http:https://couchdb.localhost:5984/hello-world/_design/recipe/_update/ingredients/SpaghettiWithMeatballs
....
> PUT /hello-world/_design/recipe/_update/ingredients/SpaghettiWithMeatballs HTTP/1.1
> Host: couchdb.localhost:5984
...
> 
....
< HTTP/1.1 201 Created
< Cache-Control: must-revalidate
...
< X-Couch-Id: SpaghettiWithMeatballs
< X-Couch-Request-ID: 2bf74089ac
< X-Couch-Update-NewRev: 5-055c4a14bbd3949a0fb5dad68ac576da
< X-CouchDB-Body-Time: 0
< 
{"status":"ok"}

POST:

curl -v -n --json 'love'  http:https://couchdb.localhost:5984/hello-world/_design/recipe/_update/ingredients/SpaghettiWithMeatballs       
...
> POST /hello-world/_design/recipe/_update/ingredients/SpaghettiWithMeatballs HTTP/1.1
> Host: couchdb.localhost:5984
...
< HTTP/1.1 201 Created
...
< 
{"status":"ok"}
* Connection #0 to host couchdb.localhost left intact

Testing recommendations

Related Issues or Pull Requests

Checklist

  • [N/A] Code is written and works correctly
  • [N/A] Changes are covered by tests
  • [N/A] Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • [N/A] Documentation changes were made in the src/docs folder
  • [N/A] Documentation changes were backported (separated PR) to affected branches

Since this is a documentation only change I assume nothing in this list applies.

@ecerulm
Copy link
Contributor Author

ecerulm commented May 31, 2023

Since apparently both PUT and POST work , should both be mentioned in the 1.5.14? Maybe indicating which one is preferred over the other (if any). User Guides > Design Documents > 3.1.5 Update Functions hint that both POST and PUT are supported when it says:

You can provide any other values needed by the update handler function via the POST/PUT entity body or query string parameters of the request.

But it both are supported I guess both should be explicitly mentioned at 1.5.14.

@nickva
Copy link
Contributor

nickva commented May 31, 2023

@ecerulm thank you for your contribution. I think in the example PUT would make more sense since we have a document ID passed in. But you're also right that it seems POST is allowed. The updater handler gets a request object and method is part of so it can choose what to do with it.

@big-r81
Copy link
Contributor

big-r81 commented May 31, 2023

@nickva should we only allow PUT like in #4449?

@nickva
Copy link
Contributor

nickva commented May 31, 2023

I was wondering about it too, @big-r81. I think it may be a compatibility issue if someone was POST.

It seems in general it's a free-for-all kind of an endpoint the _update handler js code gets to decide what to do by inspecting the method. So users may come in with a POST and a doc_id and then the _update handler may decide to do something different than if they issued a PUT request?

@nickva nickva merged commit 8b6b3e9 into apache:main May 31, 2023
6 checks passed
@nickva
Copy link
Contributor

nickva commented May 31, 2023

But perhaps we should document the behavior of if we change it, deprecate it make so gated with a feature so it won't break current 3.x users.

@ecerulm
Copy link
Contributor Author

ecerulm commented Jun 1, 2023

Since this PR is closed, I created a #4631 asking for a documentation change to document the POST /{db}/_design/{ddoc}/_update/{func}/{docid}.

@nickva
Copy link
Contributor

nickva commented Jun 1, 2023

Thank you, @ecerulm

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.

None yet

3 participants