From e311b0ed470c210a79728290b3a1311659c70a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 28 Jul 2020 13:22:09 +0200 Subject: [PATCH] fix: allow body in 201 created responses 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 --- adonis-typings/response.ts | 2 +- src/Response/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adonis-typings/response.ts b/adonis-typings/response.ts index 7d62caf..1643a93 100644 --- a/adonis-typings/response.ts +++ b/adonis-typings/response.ts @@ -372,7 +372,7 @@ declare module '@ioc:Adonis/Core/Response' { continue(): void switchingProtocols(): void ok(body: any, generateEtag?: boolean): void - created(): void + created(body?: any, generateEtag?: boolean): void accepted(body: any, generateEtag?: boolean): void nonAuthoritativeInformation(body: any, generateEtag?: boolean): void noContent(): void diff --git a/src/Response/index.ts b/src/Response/index.ts index c79245a..4d86826 100644 --- a/src/Response/index.ts +++ b/src/Response/index.ts @@ -926,9 +926,9 @@ export class Response extends Macroable implements ResponseContract { return this.send(body, generateEtag) } - public created(): void { + public created(body?: any, generateEtag?: boolean): void { this.status(201) - return this.send(null, false) + return this.send(body, generateEtag) } public accepted(body: any, generateEtag?: boolean): void {