Skip to content

Commit bd80651

Browse files
authored
fix: allow body in 201 created responses (#21)
RFC allows a payload: https://tools.ietf.org/html/rfc7231#section-6.3.2 Example in the GitHub API: https://docs.github.com/en/rest/reference/issues#create-an-issue
1 parent 855ad67 commit bd80651

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

adonis-typings/response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ declare module '@ioc:Adonis/Core/Response' {
372372
continue(): void
373373
switchingProtocols(): void
374374
ok(body: any, generateEtag?: boolean): void
375-
created(): void
375+
created(body?: any, generateEtag?: boolean): void
376376
accepted(body: any, generateEtag?: boolean): void
377377
nonAuthoritativeInformation(body: any, generateEtag?: boolean): void
378378
noContent(): void

src/Response/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,9 @@ export class Response extends Macroable implements ResponseContract {
926926
return this.send(body, generateEtag)
927927
}
928928

929-
public created(): void {
929+
public created(body?: any, generateEtag?: boolean): void {
930930
this.status(201)
931-
return this.send(null, false)
931+
return this.send(body, generateEtag)
932932
}
933933

934934
public accepted(body: any, generateEtag?: boolean): void {

0 commit comments

Comments
 (0)