Skip to content

Commit

Permalink
Documentation to explain request header casing (ruby-grape#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlism authored and basjanssen committed Feb 28, 2020
1 parent 3b5e999 commit 2d00256
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
- [Overriding Attribute Names](#overriding-attribute-names)
- [With Default](#with-default)
- [Headers](#headers)
- [Request](#request)
- [Header Case Handling](#header-case-handling)
- [Response](#response)
- [Routes](#routes)
- [Helpers](#helpers)
- [Path Helpers](#path-helpers)
Expand Down Expand Up @@ -1808,6 +1811,7 @@ end

## Headers

### Request
Request headers are available through the `headers` helper or from `env` in their original form.

```ruby
Expand All @@ -1822,6 +1826,23 @@ get do
end
```

#### Header Case Handling

The above example may have been requested as follows:

``` shell
curl -H "secret_PassWord: swordfish" ...
```

The header name will have been normalized for you.

- In the `header` helper names will be coerced into a capitalized kebab case.
- In the `env` collection they appear in all uppercase, in snake case, and prefixed with 'HTTP_'.

The header name will have been normalized per HTTP standards defined in [RFC2616 Section 4.2](https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2) regardless of what is being sent by a client.

### Response

You can set a response header with `header` inside an API.

```ruby
Expand Down

0 comments on commit 2d00256

Please sign in to comment.