Skip to content

Commit a3a28f5

Browse files
authored
Merge pull request #1532 from LeFnord/master
sets 204 as default status for delete
2 parents 152fa40 + dab3c09 commit a3a28f5

File tree

6 files changed

+114
-92
lines changed

6 files changed

+114
-92
lines changed

CHANGELOG.md

+38-72
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Next Release
2-
============
1+
### Next Release
32

43
#### Features
54

65
* [#1503](https://github.com/ruby-grape/grape/pull/1503): Allow to use regexp validator with arrays - [@akoltun](https://github.com/akoltun).
76
* [#1507](https://github.com/ruby-grape/grape/pull/1507): Add group attributes for parameter definitions - [@304](https://github.com/304).
7+
* [#1532](https://github.com/ruby-grape/grape/pull/1532): Sets 204 as default status for delete - [@LeFnord](https://github.com/LeFnord).
88
* Your contribution here.
99

1010
#### Fixes
@@ -15,10 +15,9 @@ Next Release
1515
* [#1510](https://github.com/ruby-grape/grape/pull/1510): Fix: inconsistent validation for multiple parameters - [@dgasper](https://github.com/dgasper).
1616
* [#1526](https://github.com/ruby-grape/grape/pull/1526): Reduce warnings caused by instance variables not initialized - [@cpetschnig](https://github.com/cpetschnig).
1717
* [#1531](https://github.com/ruby-grape/grape/pull/1531): Updates gem dependencies - [@LeFnord](https://github.com/LeFnord).
18+
* Your contribution here.
1819

19-
20-
0.18.0 (10/7/2016)
21-
==================
20+
### 0.18.0 (10/7/2016)
2221

2322
#### Features
2423

@@ -35,8 +34,7 @@ Next Release
3534
* [#1488](https://github.com/ruby-grape/grape/pull/1488): Ensure calling before filters when receiving OPTIONS request - [@namusyaka](https://github.com/namusyaka), [@jlfaber](https://github.com/jlfaber).
3635
* [#1493](https://github.com/ruby-grape/grape/pull/1493): Coercion and lambda fails params validation - [@jonmchan](https://github.com/jonmchan).
3736

38-
0.17.0 (7/29/2016)
39-
==================
37+
### 0.17.0 (7/29/2016)
4038

4139
#### Features
4240

@@ -64,8 +62,7 @@ Next Release
6462
* [#1421](https://github.com/ruby-grape/grape/pull/1421): Avoid polluting `Grape::Middleware::Error` - [@namusyaka](https://github.com/namusyaka).
6563
* [#1422](https://github.com/ruby-grape/grape/pull/1422): Concat parent declared params with current one - [@plukevdh](https://github.com/plukevdh), [@rnubel](https://github.com/rnubel), [@namusyaka](https://github.com/namusyaka).
6664

67-
0.16.2 (4/12/2016)
68-
==================
65+
### 0.16.2 (4/12/2016)
6966

7067
#### Features
7168

@@ -78,8 +75,7 @@ Next Release
7875
* [#1359](https://github.com/ruby-grape/grape/pull/1359): Avoid evaluating the same route twice - [@namusyaka](https://github.com/namusyaka), [@dblock](https://github.com/dblock).
7976
* [#1361](https://github.com/ruby-grape/grape/pull/1361): Return 405 correctly even if version is using as header and wrong request method - [@namusyaka](https://github.com/namusyaka), [@dblock](https://github.com/dblock).
8077

81-
0.16.1 (4/3/2016)
82-
=================
78+
### 0.16.1 (4/3/2016)
8379

8480
#### Features
8581

@@ -94,8 +90,7 @@ Next Release
9490
* [#1330](https://github.com/ruby-grape/grape/pull/1330): Add `register` keyword for adding customized parsers and formatters - [@namusyaka](https://github.com/namusyaka).
9591
* [#1336](https://github.com/ruby-grape/grape/pull/1336): Do not modify Hash argument to `error!` - [@tjwp](https://github.com/tjwp).
9692

97-
0.15.0 (3/8/2016)
98-
=================
93+
### 0.15.0 (3/8/2016)
9994

10095
#### Features
10196

@@ -122,8 +117,7 @@ Next Release
122117
* [#1283](https://github.com/ruby-grape/grape/pull/1283): Fix 500 error for xml format when method is not allowed - [@304](https://github.com/304).
123118
* [#1197](https://github.com/ruby-grape/grape/pull/1290): Fix using JSON and Array[JSON] as groups when parameter is optional - [@lukeivers](https://github.com/lukeivers).
124119

125-
0.14.0 (12/07/2015)
126-
=================
120+
### 0.14.0 (12/07/2015)
127121

128122
#### Features
129123

@@ -150,8 +144,7 @@ Next Release
150144
* [#1101](https://github.com/ruby-grape/grape/pull/1101): Fix: Incorrect media-type `Accept` header now correctly returns 406 with `strict: true` - [@elliotlarson](https://github.com/elliotlarson).
151145
* [#1108](https://github.com/ruby-grape/grape/pull/1039): Raise a warning when `desc` is called with options hash and block - [@rngtng](https://github.com/rngtng).
152146

153-
0.13.0 (8/10/2015)
154-
==================
147+
### 0.13.0 (8/10/2015)
155148

156149
#### Features
157150

@@ -172,8 +165,7 @@ Next Release
172165
* [#1088](https://github.com/ruby-grape/grape/pull/1088): Support ActiveSupport 3.x by explicitly requiring `Hash#except` - [@wagenet](https://github.com/wagenet).
173166
* [#1096](https://github.com/ruby-grape/grape/pull/1096): Fix coercion on booleans - [@towanda](https://github.com/towanda).
174167

175-
0.12.0 (6/18/2015)
176-
==================
168+
### 0.12.0 (6/18/2015)
177169

178170
#### Features
179171

@@ -199,8 +191,7 @@ Next Release
199191
* [#1023](https://github.com/ruby-grape/grape/issues/1023): Fixes unexpected behavior with `present` and an object that responds to `merge` but isn't a Hash - [@dblock](https://github.com/dblock).
200192
* [#1017](https://github.com/ruby-grape/grape/pull/1017): Fixed `undefined method stringify_keys` with nested mutual exclusive params - [@quickpay](https://github.com/quickpay).
201193

202-
0.11.0 (2/23/2015)
203-
==================
194+
### 0.11.0 (2/23/2015)
204195

205196
* [#925](https://github.com/ruby-grape/grape/pull/925): Fixed `toplevel constant DateTime referenced by Virtus::Attribute::DateTime` - [@u2](https://github.com/u2).
206197
* [#916](https://github.com/ruby-grape/grape/pull/916): Added `DateTime/Date/Numeric/Boolean` type support `allow_blank` - [@u2](https://github.com/u2).
@@ -217,14 +208,12 @@ Next Release
217208
* [#913](https://github.com/ruby-grape/grape/pull/913): Fix: Invalid accept headers cause internal processing errors (500) when http_codes are defined - [@croeck](https://github.com/croeck).
218209
* [#917](https://github.com/ruby-grape/grape/pull/917): Use HTTPS for rubygems.org - [@O-I](https://github.com/O-I).
219210

220-
0.10.1 (12/28/2014)
221-
===================
211+
### 0.10.1 (12/28/2014)
222212

223213
* [#868](https://github.com/ruby-grape/grape/pull/868), [#862](https://github.com/ruby-grape/grape/pull/862), [#861](https://github.com/ruby-grape/grape/pull/861): Fixed `version`, `prefix`, and other settings being overridden or changing scope when mounting API - [@yesmeck](https://github.com/yesmeck).
224214
* [#864](https://github.com/ruby-grape/grape/pull/864): Fixed `declared(params, include_missing: false)` now returning attributes with `nil` and `false` values - [@ppadron](https://github.com/ppadron).
225215

226-
0.10.0 (12/19/2014)
227-
===================
216+
### 0.10.0 (12/19/2014)
228217

229218
* [#803](https://github.com/ruby-grape/grape/pull/803), [#820](https://github.com/ruby-grape/grape/pull/820): Added `all_or_none_of` parameter validator - [@loveltyoic](https://github.com/loveltyoic), [@natecj](https://github.com/natecj).
230219
* [#774](https://github.com/ruby-grape/grape/pull/774): Extended `mutually_exclusive`, `exactly_one_of`, `at_least_one_of` to work inside any kind of group: `requires` or `optional`, `Hash` or `Array` - [@ShPakvel](https://github.com/ShPakvel).
@@ -247,8 +236,7 @@ Next Release
247236
* [#679](https://github.com/ruby-grape/grape/issues/679): Fixed `OPTIONS` method returning 404 when combined with `prefix` - [@dblock](https://github.com/dblock).
248237
* [#679](https://github.com/ruby-grape/grape/issues/679): Fixed unsupported methods returning 404 instead of 405 when combined with `prefix` - [@dblock](https://github.com/dblock).
249238

250-
0.9.0 (8/27/2014)
251-
=================
239+
### 0.9.0 (8/27/2014)
252240

253241
#### Features
254242

@@ -266,8 +254,7 @@ Next Release
266254

267255
* [#687](https://github.com/ruby-grape/grape/pull/687): Fix: `mutually_exclusive` and `exactly_one_of` validation error messages now label parameters as strings, consistently with `requires` and `optional` - [@dblock](https://github.com/dblock).
268256

269-
0.8.0 (7/10/2014)
270-
=================
257+
### 0.8.0 (7/10/2014)
271258

272259
#### Features
273260

@@ -287,8 +274,7 @@ Next Release
287274
* [#619](https://github.com/ruby-grape/grape/pull/619): Convert specs to RSpec 3 syntax with Transpec - [@danielspector](https://github.com/danielspector).
288275
* [#632](https://github.com/ruby-grape/grape/pull/632): `Grape::Endpoint#present` causes ActiveRecord to make an extra query during entity's detection - [@fixme](https://github.com/fixme).
289276

290-
0.7.0 (4/2/2014)
291-
=================
277+
### 0.7.0 (4/2/2014)
292278

293279
#### Features
294280

@@ -322,13 +308,12 @@ Next Release
322308
* [#512](https://github.com/ruby-grape/grape/pull/512): Don't create `Grape::Request` multiple times - [@dblock](https://github.com/dblock).
323309
* [#538](https://github.com/ruby-grape/grape/pull/538): Fixed default values for grouped params - [@dm1try](https://github.com/dm1try).
324310
* [#549](https://github.com/ruby-grape/grape/pull/549): Fixed handling of invalid version headers to return 406 if a header cannot be parsed - [@bwalex](https://github.com/bwalex).
325-
* [#557](https://github.com/ruby-grape/grape/pull/557): Pass `content_types` option to `Grape::Middleware::Error` to fix the content-type header for custom formats. - [@bernd](https://github.com/bernd).
311+
* [#557](https://github.com/ruby-grape/grape/pull/557): Pass `content_types` option to `Grape::Middleware::Error` to fix the content-type header for custom formats - [@bernd](https://github.com/bernd).
326312
* [#585](https://github.com/ruby-grape/grape/pull/585): Fix after boot thread-safety issue - [@etehtsea](https://github.com/etehtsea).
327313
* [#587](https://github.com/ruby-grape/grape/pull/587): Fix oauth2 middleware compatibility with [draft-ietf-oauth-v2-31](http://tools.ietf.org/html/draft-ietf-oauth-v2-31) spec - [@etehtsea](https://github.com/etehtsea).
328314
* [#610](https://github.com/ruby-grape/grape/pull/610): Fixed group keyword was not working with type parameter - [@klausmeyer](https://github.com/klausmeyer).
329315

330-
0.6.1 (10/19/2013)
331-
==================
316+
### 0.6.1 (10/19/2013)
332317

333318
#### Features
334319

@@ -344,8 +329,7 @@ Next Release
344329

345330
* Implemented Rubocop, a Ruby code static code analyzer - [@dblock](https://github.com/dblock).
346331

347-
0.6.0 (9/16/2013)
348-
=================
332+
### 0.6.0 (9/16/2013)
349333

350334
#### Features
351335

@@ -363,8 +347,7 @@ Next Release
363347

364348
* [#428](https://github.com/ruby-grape/grape/issues/428): Removes memoization from `Grape::Request` params to prevent middleware from freezing parameter values before `Formatter` can get them - [@mbleigh](https://github.com/mbleigh).
365349

366-
0.5.0 (6/14/2013)
367-
=================
350+
### 0.5.0 (6/14/2013)
368351

369352
#### Features
370353

@@ -390,13 +373,11 @@ Next Release
390373
* [#423](https://github.com/ruby-grape/grape/pull/423): Fix: `Grape::Endpoint#declared` now correctly handles nested params (ie. declared with `group`) - [@jbarreneche](https://github.com/jbarreneche).
391374
* [#427](https://github.com/ruby-grape/grape/issues/427): Fix: `declared(params)` breaks when `params` contains array - [@timhabermaas](https://github.com/timhabermaas).
392375

393-
0.4.1 (4/1/2013)
394-
================
376+
### 0.4.1 (4/1/2013)
395377

396378
* [#375](https://github.com/ruby-grape/grape/pull/375): Fix: throwing an `:error` inside a middleware doesn't respect the `format` settings - [@dblock](https://github.com/dblock).
397379

398-
0.4.0 (3/17/2013)
399-
=================
380+
### 0.4.0 (3/17/2013)
400381

401382
* [#356](https://github.com/ruby-grape/grape/pull/356): Fix: presenting collections other than `Array` (eg. `ActiveRecord::Relation`) - [@zimbatm](https://github.com/zimbatm).
402383
* [#352](https://github.com/ruby-grape/grape/pull/352): Fix: using `Rack::JSONP` with `Grape::Entity` responses - [@deckchair](https://github.com/deckchair).
@@ -410,18 +391,15 @@ Next Release
410391
* [#353](https://github.com/ruby-grape/grape/issues/353): Revert to standard Ruby logger formatter, `require active_support/all` if you want old behavior - [@rhunter](https://github.com/rhunter), [@dblock](https://github.com/dblock).
411392
* Fix: `undefined method 'call' for nil:NilClass` for an API method implementation without a block, now returns an empty string - [@dblock](https://github.com/dblock).
412393

413-
0.3.2 (2/28/2013)
414-
=================
394+
### 0.3.2 (2/28/2013)
415395

416396
* [#355](https://github.com/ruby-grape/grape/issues/355): Relax dependency constraint on Hashie - [@reset](https://github.com/reset).
417397

418-
0.3.1 (2/25/2013)
419-
=================
398+
### 0.3.1 (2/25/2013)
420399

421400
* [#351](https://github.com/ruby-grape/grape/issues/351): Compatibility with Ruby 2.0 - [@mbleigh](https://github.com/mbleigh).
422401

423-
0.3.0 (02/21/2013)
424-
==================
402+
### 0.3.0 (02/21/2013)
425403

426404
* [#294](https://github.com/ruby-grape/grape/issues/294): Extracted `Grape::Entity` into a [grape-entity](https://github.com/agileanimal/grape-entity) gem - [@agileanimal](https://github.com/agileanimal).
427405
* [#340](https://github.com/ruby-grape/grape/pull/339), [#342](https://github.com/ruby-grape/grape/pull/342): Added `:cascade` option to `version` to allow disabling of rack/mount cascade behavior - [@dieb](https://github.com/dieb).
@@ -440,14 +418,12 @@ Next Release
440418
* [#60](https://github.com/ruby-grape/grape/issues/60): Fix: mounting of a Grape API onto a path - [@dblock](https://github.com/dblock).
441419
* [#335](https://github.com/ruby-grape/grape/pull/335): Fix: request body parameters from a `PATCH` request not available in `params` - [@FreakenK](https://github.com/FreakenK).
442420

443-
0.2.6 (01/11/2013)
444-
==================
421+
### 0.2.6 (01/11/2013)
445422

446423
* Fix: support content-type with character set when parsing POST and PUT input - [@dblock](https://github.com/dblock).
447424
* Fix: CVE-2013-0175, multi_xml parse vulnerability, require multi_xml 0.5.2 - [@dblock](https://github.com/dblock).
448425

449-
0.2.5 (01/10/2013)
450-
==================
426+
### 0.2.5 (01/10/2013)
451427

452428
* Added support for custom parsers via `parser`, in addition to built-in multipart, JSON and XML parsers - [@dblock](https://github.com/dblock).
453429
* Removed `body_params`, data sent via a POST or PUT with a supported content-type is merged into `params` - [@dblock](https://github.com/dblock).
@@ -456,8 +432,7 @@ Next Release
456432
* [#305](https://github.com/ruby-grape/grape/issues/305): Fix: presenting arrays of objects via `represent` or when auto-detecting an `Entity` constant in the objects being presented - [@brandonweiss](https://github.com/brandonweiss).
457433
* [#306](https://github.com/ruby-grape/grape/issues/306): Added i18n support for validation error messages - [@niedhui](https://github.com/niedhui).
458434

459-
0.2.4 (01/06/2013)
460-
==================
435+
### 0.2.4 (01/06/2013)
461436

462437
* [#297](https://github.com/ruby-grape/grape/issues/297): Added `default_error_formatter` - [@dblock](https://github.com/dblock).
463438
* [#297](https://github.com/ruby-grape/grape/issues/297): Setting `format` will automatically set `default_error_formatter` - [@dblock](https://github.com/dblock).
@@ -475,8 +450,7 @@ Next Release
475450
* [#304](https://github.com/ruby-grape/grape/issues/304): Fix: `present x, :with => Entity` returns class references with `format :json` - [@dblock](https://github.com/dblock).
476451
* [#196](https://github.com/ruby-grape/grape/issues/196): Fix: root requests don't work with `prefix` - [@dblock](https://github.com/dblock).
477452

478-
0.2.3 (24/12/2012)
479-
==================
453+
### 0.2.3 (24/12/2012)
480454

481455
* [#179](https://github.com/ruby-grape/grape/issues/178): Using `content_type` will remove all default content-types - [@dblock](https://github.com/dblock).
482456
* [#265](https://github.com/ruby-grape/grape/issues/264): Fix: Moved `ValidationError` into `Grape::Exceptions` - [@thepumpkin1979](https://github.com/thepumpkin1979).
@@ -489,8 +463,7 @@ Next Release
489463
* [#290](https://github.com/ruby-grape/grape/pull/290): The default error format for XML is now `error/message` instead of `hash/error` - [@dpsk](https://github.com/dpsk).
490464
* [#44](https://github.com/ruby-grape/grape/issues/44): Pass `env` into formatters to enable templating - [@dblock](https://github.com/dblock).
491465

492-
0.2.2
493-
=====
466+
### 0.2.2 (12/10/2012)
494467

495468
#### Features
496469

@@ -512,8 +485,7 @@ Next Release
512485
* [#208](https://github.com/ruby-grape/grape/pull/208): `Entity#serializable_hash` must also check if attribute is generated by a user supplied block - [@ppadron](https://github.com/ppadron).
513486
* [#252](https://github.com/ruby-grape/grape/pull/252): Resources that don't respond to a requested HTTP method return 405 (Method Not Allowed) instead of 404 (Not Found) - [@simulacre](https://github.com/simulacre).
514487

515-
0.2.1 (7/11/2012)
516-
=================
488+
### 0.2.1 (7/11/2012)
517489

518490
* [#186](https://github.com/ruby-grape/grape/issues/186): Fix: helpers allow multiple calls with modules and blocks - [@ppadron](https://github.com/ppadron).
519491
* [#188](https://github.com/ruby-grape/grape/pull/188): Fix: multi-method routes append '(.:format)' only once - [@kainosnoema](https://github.com/kainosnoema).
@@ -528,8 +500,7 @@ Next Release
528500
* [#189](https://github.com/ruby-grape/grape/pull/189): `HEAD` requests no longer return a body - [@stephencelis](https://github.com/stephencelis).
529501
* [#97](https://github.com/ruby-grape/grape/issues/97): Allow overriding `Content-Type` - [@dblock](https://github.com/dblock).
530502

531-
0.2.0 (3/28/2012)
532-
=================
503+
### 0.2.0 (3/28/2012)
533504

534505
* Added support for inheriting exposures from entities - [@bobbytables](https://github.com/bobbytables).
535506
* Extended formatting with `default_format` - [@dblock](https://github.com/dblock).
@@ -549,33 +520,28 @@ Next Release
549520
* Added support for before and after filters - [@mbleigh](https://github.com/mbleigh).
550521
* Extended `rescue_from`, which can now take a block - [@dblock](https://github.com/dblock).
551522

552-
0.1.5 (6/14/2011)
553-
==================
523+
### 0.1.5 (6/14/2011)
554524

555525
* Extended exception handling to all exceptions - [@dblock](https://github.com/dblock).
556526
* Added support for returning JSON objects from within error blocks - [@dblock](https://github.com/dblock).
557527
* Added support for handling incoming JSON in body - [@tedkulp](https://github.com/tedkulp).
558528
* Added support for HTTP digest authentication - [@daddz](https://github.com/daddz).
559529

560-
0.1.4 (4/8/2011)
561-
==================
530+
### 0.1.4 (4/8/2011)
562531

563532
* Allow multiple definitions of the same endpoint under multiple versions - [@chrisrhoden](https://github.com/chrisrhoden).
564533
* Added support for multipart URL parameters - [@mcastilho](https://github.com/mcastilho).
565534
* Added support for custom formatters - [@spraints](https://github.com/spraints).
566535

567-
0.1.3 (1/10/2011)
568-
==================
536+
### 0.1.3 (1/10/2011)
569537

570538
* Added support for JSON format in route matching - [@aiwilliams](https://github.com/aiwilliams).
571539
* Added suport for custom middleware - [@mbleigh](https://github.com/mbleigh).
572540

573-
0.1.1 (11/14/2010)
574-
==================
541+
### 0.1.1 (11/14/2010)
575542

576543
* Endpoints properly reset between each request - [@mbleigh](https://github.com/mbleigh).
577544

578-
0.1.0 (11/13/2010)
579-
==================
545+
### 0.1.0 (11/13/2010)
580546

581547
* Initial public release - [@mbleigh](https://github.com/mbleigh).

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ cookies.delete :status_count, path: '/'
17411741

17421742
## HTTP Status Code
17431743

1744-
By default Grape returns a 200 status code for `GET`-Requests and 201 for `POST`-Requests.
1744+
By default Grape returns a 201 for `POST`-Requests, 204 for `DELETE`-Requests and 200 status code for all other Requests.
17451745
You can use `status` to query and set the actual HTTP Status Code
17461746

17471747
```ruby

UPGRADING.md

+15
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ Prior to this version the response would be `one is missing`.
4141

4242
See [#1510](https://github.com/ruby-grape/grape/pull/1510) for more information.
4343

44+
#### The default status code for DELETE is now 204 instead of 200.
45+
46+
Breaking change: Sets the default response status code for a delete request to 204.
47+
A status of 204 makes the response more distinguishable and therefore easier to handle on the client side, particularly because a DELETE request typically returns an empty body as the resource was deleted or voided.
48+
49+
To achieve the old behavior, one has to set it explicitly:
50+
```ruby
51+
delete :id do
52+
status 200
53+
'foo successfully deleted'
54+
end
55+
```
56+
57+
For more information see: [#1532](https://github.com/ruby-grape/grape/pull/1532).
58+
4459
### Upgrading to >= 0.17.0
4560

4661
#### Removed official support for Ruby < 2.2.2

lib/grape/dsl/inside_route.rb

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def status(status = nil)
129129
case request.request_method.to_s.upcase
130130
when Grape::Http::Headers::POST
131131
201
132+
when Grape::Http::Headers::DELETE
133+
204
132134
else
133135
200
134136
end

0 commit comments

Comments
 (0)