Skip to content

Commit d72deda

Browse files
committed
Document header DSL
1 parent 5545bbc commit d72deda

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,25 @@ resource "Orders" do
274274
end
275275
```
276276

277+
#### header
278+
279+
This method takes the header name and value. The value can be a string or a symbol. If it is a symbol it will `send` the symbol, allowing you to `let` header values.
280+
281+
```ruby
282+
resource "Orders" do
283+
header "Accept", "application/json"
284+
header "X-Custom", :custom_header
285+
286+
let(:custom_header) { "dynamic" }
287+
288+
get "/orders" do
289+
example_request "Headers" do
290+
headers.should == { "Accept" => "application/json", "X-Custom" => "dynamic" }
291+
end
292+
end
293+
end
294+
```
295+
277296
#### parameter
278297

279298
This method takes the parameter name, a description, and an optional hash of extra metadata that can be displayed in Raddocs as extra columns. If a method with the parameter name exists, e.g. a `let`, it will send the returned value up to the server as URL encoded data.
@@ -381,6 +400,28 @@ end
381400

382401
Get a hash of parameters that will be sent. See `parameter` documentation for an example.
383402

403+
#### header
404+
405+
This method takes the header name and value.
406+
407+
```ruby
408+
resource "Orders" do
409+
before do
410+
header "Accept", "application/json"
411+
end
412+
413+
get "/orders" do
414+
example_request "Headers" do
415+
headers.should == { "Accept" => "application/json" }
416+
end
417+
end
418+
end
419+
```
420+
421+
#### headers
422+
423+
This returns the headers that were sent as the request. See `header` documentation for an example.
424+
384425
#### response_body
385426

386427
Returns a string containing the response body from the previous request.

0 commit comments

Comments
 (0)