You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the first matching version is used when no Accept header is supplied. This behavior is similar to routing in Rails.
85
+
To circumvent this default behaviour, one could use the `:strict` option. When this option is set to `true`, a `404 Not found` error is returned when no correct Accept header is supplied.
86
+
84
87
Serialization takes place automatically. For more detailed usage information, please visit the [Grape Wiki](http://github.com/intridea/grape/wiki).
85
88
86
89
## Working with Entities
@@ -105,7 +108,7 @@ class API < Grape::API
105
108
version 'v1', 'v2'
106
109
107
110
get '/users/:id'do
108
-
present User.find(params[:id]),
111
+
present User.find(params[:id]),
109
112
:with => Entities::User,
110
113
:authenticated => env.key?('api.token')
111
114
end
@@ -191,9 +194,9 @@ You can test a Grape API with RSpec. Tests make HTTP requests, therefore they mu
Grape exposes arrays of API versions and compiled routes. Each route contains a `route_prefix`, `route_version`, `route_namespace`, `route_method`, `route_path` and `route_params`.
219
222
220
223
```ruby
221
-
classTwitterAPI < Grape::API
224
+
classTwitterAPI < Grape::API
222
225
223
226
version 'v1'
224
-
get "version"do
227
+
get "version"do
225
228
api.version
226
229
end
227
230
@@ -242,7 +245,7 @@ Grape also supports storing additional parameters with the route information. Th
242
245
243
246
```ruby
244
247
classStringAPI < Grape::API
245
-
get "split/:string", { :params => [ "token" ], :optional_params => [ "limit" ] } do
248
+
get "split/:string", { :params => [ "token" ], :optional_params => [ "limit" ] } do
0 commit comments