@@ -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
120122Using 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
133137Using 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
143149Using 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
147153The 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
155163Parameters are available through the ` params ` hash object. This includes ` GET ` and ` POST ` parameters,
156164along 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
164172Parameters are also populated from the request body on POST and PUT for JSON and XML content-types.
165173
166174The 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
170178The 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
179188Headers 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