Skip to content

Commit 089b2ce

Browse files
committed
Markdown edits in README.
1 parent 06310eb commit 089b2ce

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

README.markdown

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ There are three strategies in which clients can reach your API's endpoints: `:he
115115

116116
### Header
117117

118-
version 'v1', :using => :header
118+
```ruby
119+
version 'v1', :using => :header
120+
```
119121

120122
Using this versioning strategy, clients should pass the desired version in the HTTP Accept head.
121123

@@ -128,7 +130,9 @@ is returned when no correct Accept header is supplied.
128130

129131
### Path
130132

131-
version 'v1', :using => :path
133+
``` ruby
134+
version 'v1', :using => :path
135+
```
132136

133137
Using this versioning strategy, clients should pass the desired version in the URL.
134138

@@ -138,51 +142,56 @@ Serialization takes place automatically.
138142

139143
### Param
140144

141-
version 'v1', :using => :param
145+
```ruby
146+
version 'v1', :using => :param
147+
```
142148

143149
Using this versioning strategy, clients should pass the desired version as a request parameter, either in the URL query string or in the request body.
144150

145151
curl -H http://localhost:9292/events?apiver=v1
146152

147153
The default name for the query parameter is 'apiver' but can be specified using the :parameter option.
148154

149-
version 'v1', :using => :param, :parameter => "v"
150-
curl -H http://localhost:9292/events?v=v1
155+
```ruby
156+
version 'v1', :using => :param, :parameter => "v"
157+
```
151158

159+
curl -H http://localhost:9292/events?v=v1
152160

153161
## Parameters
154162

155163
Parameters are available through the `params` hash object. This includes `GET` and `POST` parameters,
156164
along with any named parameters you specify in your route strings.
157165

158166
```ruby
159-
get do
167+
get do
160168
Article.order(params[:sort_by])
161-
end
169+
end
162170
```
163171

164172
Parameters are also populated from the request body on POST and PUT for JSON and XML content-types.
165173

166174
The Request:
167-
```curl -d '{"some_key": "some_value"}' 'http://localhost:9292/json_endpoint' -H Content-Type:application/json -v```
168175

176+
```curl -d '{"some_key": "some_value"}' 'http://localhost:9292/json_endpoint' -H Content-Type:application/json -v```
169177

170178
The Grape Endpoint:
179+
171180
```ruby
172-
post '/json_endpoint' do
181+
post '/json_endpoint' do
173182
params[:some_key]
174-
end
183+
end
175184
```
176185

177186
## Headers
178187

179188
Headers are available through the `env` hash object.
180189

181190
```ruby
182-
get do
191+
get do
183192
error! 'Unauthorized', 401 unless env['HTTP_SECRET_PASSWORD'] == 'swordfish'
184193
...
185-
end
194+
end
186195
```
187196

188197
## Helpers

0 commit comments

Comments
 (0)