mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Allow IfNeededConverter to short-circuit.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import type { Representation } from '../../ldp/representation/Representation';
|
||||
import { getLoggerFor } from '../../logging/LogUtil';
|
||||
import { InternalServerError } from '../../util/errors/InternalServerError';
|
||||
import { UnsupportedAsyncHandler } from '../../util/UnsupportedAsyncHandler';
|
||||
import { matchingMediaTypes } from './ConversionUtil';
|
||||
import { RepresentationConverter } from './RepresentationConverter';
|
||||
import type { RepresentationConverterArgs } from './RepresentationConverter';
|
||||
|
||||
const EMPTY_CONVERTER = new UnsupportedAsyncHandler('The content type does not match the preferences');
|
||||
|
||||
/**
|
||||
* A {@link RepresentationConverter} that only converts representations
|
||||
* that are not compatible with the preferences.
|
||||
@@ -13,7 +16,7 @@ export class IfNeededConverter extends RepresentationConverter {
|
||||
private readonly converter: RepresentationConverter;
|
||||
protected readonly logger = getLoggerFor(this);
|
||||
|
||||
public constructor(converter: RepresentationConverter) {
|
||||
public constructor(converter: RepresentationConverter = EMPTY_CONVERTER) {
|
||||
super();
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user