1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-21 13:47:39 +02:00

#1391: fix remaining 201 location headers missing

This commit is contained in:
Thomas Heartman 2022-09-14 11:52:14 +02:00
parent fe07191c63
commit d29400d59a
3 changed files with 9 additions and 1 deletions

View File

@ -165,6 +165,7 @@ export class ApiTokenController extends Controller {
res, res,
apiTokenSchema.$id, apiTokenSchema.$id,
serializeDates(token), serializeDates(token),
{ location: `api-tokens` },
); );
} }

View File

@ -169,7 +169,9 @@ class TagTypeController extends Controller {
req.body, req.body,
userName, userName,
); );
res.status(201).json(tagType); res.status(201)
.header('location', `tag-types/${tagType.name}`)
.json(tagType);
} }
async updateTagType( async updateTagType(

View File

@ -69,6 +69,7 @@ export class OpenApiService {
res: Response<T>, res: Response<T>,
schema: SchemaId, schema: SchemaId,
data: T, data: T,
headers: { [header: string]: string } = {},
): void { ): void {
const errors = validateSchema(schema, data); const errors = validateSchema(schema, data);
@ -76,6 +77,10 @@ export class OpenApiService {
this.logger.debug('Invalid response:', errors); this.logger.debug('Invalid response:', errors);
} }
Object.entries(headers).forEach(([header, value]) =>
res.header(header, value),
);
res.status(status).json(data); res.status(status).json(data);
} }
} }