Skip to content

Add more Layout Renderers for Minimal API #1100

@ramil-mux

Description

@ramil-mux

In new projects on .net 9 I use Minimal API endpoints. Previously controllers had special Layout Renders ${aspnet-mvc-action} and ${aspnet-mvc-controller}, but endpoints do not have such a concept as action name and controller name. Endpoints mainly use metadata. For example, endpoint has methods WithDisplayName and WithGroupName, which I want to try to use similarly to display the action name and the controller name, but NLog does not have properties to render this metadata, only ${aspnet-request-endpoint} for render DisplayName.

orderTemplateGroup
    .MapGet("/{id:int}", GetTemplateHandler.GetOrderTemplate)
    .WithName("GetOrderTemplateName")
    .WithDisplayName("GetOrderTemplateDisplayName")
    .WithGroupName("OrderTemplateGroupName"));

My NLog.config for experiments

<target name="mainTarget" xsi:type="AsyncWrapper">
    <target xsi:type="Console" stderr="false">
        <layout xsi:type="JsonLayout" maxRecursionLimit="2" includeEventProperties="false">
            <attribute name="ControllerName"   layout="${aspnet-mvc-controller}" />
            <attribute name="ControllerName2"   layout="${aspnet-request-endpoint}" />
        </layout>
    </target>
</target>

How can I add additional metadata to a render? For instance, how can I add group name metadata to render?
Will new Layout Renderers be added to support displaying endpoint metadata?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions