feat: Add moer element
Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import ResponseBuilder from '../ResponseBuilder'
|
||||
|
||||
/**
|
||||
* Add headers:
|
||||
@ -57,11 +58,9 @@ export default interface RFC7807 {
|
||||
* @param error the error (base items are type, status, title details and instance)
|
||||
* @returns
|
||||
*/
|
||||
export function buildRFC7807(error: RFC7807 & Record<string, any>): Response {
|
||||
return new Response(JSON.stringify(error), {
|
||||
headers: {
|
||||
'Content-Type': 'application/problem+json'
|
||||
},
|
||||
status: error.status ?? 500
|
||||
})
|
||||
export function buildRFC7807(error: RFC7807 & Record<string, any>, response: ResponseBuilder = new ResponseBuilder()): Response {
|
||||
response.addHeader('Content-Type', 'application/problem+json')
|
||||
.body(JSON.stringify(error))
|
||||
.status(error.status ?? 500)
|
||||
return response.build()
|
||||
}
|
||||
|
Reference in New Issue
Block a user