This repository has been archived by the owner on May 12, 2018. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
this is PR 3/3 as discussed in #12.
A
DecoderManager
is used to manage different decoders for different media types. The logic which decoder may be used is implemented in the Loaders and based on the output of the newdetermineMediaType
function.determineMediaType
evaluates first the Content-Type header, then the file extension and defaults to null if no type can be determined. TheDecoderManager
has an option to register a defaultType which is used in case that the type is unknown or can not be determined. If no arguments are provided, theDecoderManager
registers the Json-Decoder and makes it default for all types. The Yaml decoder is not register per default as discussed.Open Points
determineMediaType
Right now the decoder fails if the content type is set, but no decoder is registered for this content type, except for the content type "application/octet-stream". In that case the file extension is used if present.
I think functions is not the right place for this logic, maybe it would be better to do it in the
DecoderManger
and make it pluggable. I'm not so happy about the huge amount of logic which is already there, because it get too complex, but I dont know a better solution at the moment.Integrating the logic with the
DecoderManger
opens another option, namely to test if parsing is possible if now type can be determined from the headers or file extension. Then theDecoderManager
should keep track about the Decoders in such a way, that no decoder is tested twice.parseContentTypeHeader, parseHttpResponseHeader
Those functions may be extracted to their own library?
getDecoderManager, setDecoderManager (LoaderManager)
The
LoaderManager
has agetDecoderManager
method which allows the DecoderManager to be access (e.g. to add a Decoder) easily.Instead of passing the Decoder directly to the Loader, the DecoderManager is passed. The DecoderManager can not be replaced easily, since it would have to be replaced in all Loaders. This would requiere a new function in each Loader or a Proxy Object. Therefore the LoaderManger does not have a
setDecoderManager
. This feals a bit complex. Maybe there is a better way to manage this?Looking forward for Feedback!