Map Custom Content-Type to Json without popping up in metadata page

Hi Demis,
we have to implement a webhook endpoint. Unfortunately the other service calls our endpoint with Content-Type: application/vnd.layer.webhooks+json;v=1. So SS can’t deserialize the DTO because of that OOB.

So we quickly registered another ContentType with appHost.ContentTypes.Register("application/vnd.layer.webhooks+json", LayerResponsSerializer, LayerRequestSerializer);

and the following methods:

    private object LayerRequestSerializer(Type type, Stream fromstream)
        return JsonSerializer.DeserializeFromStream(type, fromstream);

    private void LayerResponsSerializer(IRequest requestcontext, object dto, Stream outputstream)
        JsonSerializer.SerializeToStream(dto, outputstream);

The ResponseSerializer is actually not needed.

This works, the only thing that bugs me is the metadata page: it shows next to json/html&co also this content type:

Is there a way to tell SS to serialize application/vnd.layer.webhook+json as JSON without enabling another content-type for responses?

If not, i’m probably just going to rewrite the Content-Type to application/json with a pre request filter.


Your Serializer/Deserializer determines what ServiceStack should call to process the new format, but you can remove it from the metadata pages with:

SetConfig(new HostConfig {
    IgnoreFormatsInMetadata = { "vnd.layer.webhooks+json" }