Wednesday, August 9, 2017

Using curb with custom verb/methods, headers and body.

The Easy method of Curb does not allow arbitrary request methods to be made.

Instead of using Easy, you can use the Curl module. In curb's rubydoc, you'll see hardly any description of these methods, so I explain them here.

There are methods named after REST verbs in the Curl module and there's http method which allows you to send custom verbs. These methods also take a code block in which case it'll pass a newly created object (just like as the first argument to the body. All instance methods which applies to the object of also apply to this object. Before existing the code block, the request will be made.