When they say a method is "Idempotency", in Go, is it considered a convention/standard? or is there something else?

When I see this:

POST   => create a new object
DELETE => delete an object
PUT    => modify an object

Some say things like this method is Idempotent and this one is not.

But I see that I can do all of that with POST, the big difference I find is that using different methods allows documenting an API, organizing the code, easy communication with other APIs that follow the same standard, etc.

Is that correct? or is there something else? such as Go internally treats each method differently, so far I haven’t seen Go do that, but what do I know.

Anyway, are those verbs just strings and the implementation is left to me? or does Go do some mischief to follow that standard?

It is no a only Go concept but mathematical. In a general way, it means that calling many times a function with the same input, you will get the same results. To have a better explanation, check What is Idempotency?

that definition may be correct but adds nothing to what the OP probably has already read.

in practice it really means

“no matter how many times a function is called its behavior, specifically side effects, should be the same as only calling it once”.

also you have POST and PUT reversed.

POST is for RPC like tasks, PUT is for just that PUTing new resources or updating existing resources in place.

idempotent PUT means no matter how many times you call PUT with the same input data it only creates the resource once, updates would not change the resource state either.

It’s good that everything is clarified

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.