corvus-dotnet / corvus-dotnet/Corvus.ContentHandling

Add docs for fallback behaviour when resolving a content handler

Open
#105 3 comments 0 reactions 1 assignee Claimed by @idg10 View on GitHub
Dominant language
C#
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

An internal discussion revealed an opportunity to improve the documentation: it revealed insufficient clarity around the fallback mechanisms.

This is a paraphrased version of the conversation:

Alice asked:
>I have `IPageParser` registered against `application/vnd.endjin.ssg.page+yaml` but I load a type with a content type of `application/vnd.endjin.ssg.page.section+yaml` should I still get a fall back of `IPageParser`?

Bob replied:
> Yes, you should.

Alice persisted:
> Do I have to do anything special on the registration side or use a different API to resolve? If I'm currently using `this.serviceProvider.GetContent(page.ContentType)`

Bob responded:
> Ah, it would need `$"{page.ContentType}+yaml"`
> And when you register the content renderer likewise.
> We have code specifically to help you with registering these kinds of handlers, though.

Alice continued:
> I'm using `factory.RegisterTransientContent(ContentTypes.OpenSourceProject);` to register for content parsers where `ContentTypes.OpenSourceProject` is `application/vnd.endjin.ssg.opensource.project+md`

Bob said:
>Oh, that should be fine then.
>But we have the concept of `IContentHandler`. And dispatching to the handler for you.
> https://github.com/corvus-dotnet/Corvus.ContentHandling/blob/master/Solutions/Corvus.ContentHandling/Corvus/ContentHandling/IContentHandlerDispatcher%7BTPayloadBaseType%7D.cs
> Take a look at the docs in there. This is precisely your use case.
> There's a complete example here https://github.com/corvus-dotnet/Corvus.ContentHandling/blob/ce68da19e56cbd5376a3182d3339ce5f9696efdb/Solutions/Corvus.ContentHandling/Corvus/ContentHandling/IContentHandlerDispatcher%7BTPayloadBaseType%7D.cs#L291

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.