change: Support all PUT operations, error later

This commit is contained in:
Ruben Verborgh
2020-09-02 17:27:32 +02:00
committed by Joachim Van Herwegen
parent 4965b476c9
commit 385e1a4cdf
2 changed files with 10 additions and 7 deletions

View File

@@ -20,13 +20,13 @@ export class PutOperationHandler extends OperationHandler {
if (input.method !== 'PUT') {
throw new UnsupportedHttpError('This handler only supports PUT operations.');
}
if (typeof input.body !== 'object') {
throw new UnsupportedHttpError('PUT operations require a body.');
}
}
public async handle(input: Operation): Promise<ResponseDescription> {
await this.store.setRepresentation(input.target, input.body!);
if (typeof input.body !== 'object') {
throw new UnsupportedHttpError('PUT operations require a body.');
}
await this.store.setRepresentation(input.target, input.body);
return { identifier: input.target };
}
}