Skip to content

Informatievlaanderen/guid-header-modelbinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Be.Vlaanderen.Basisregisters.AspNetCore.Mvc.ModelBinding.GuidHeader Build Status

An MVC ModelBinder for GUID type or GUID as string, which also looks in the header.

Usage

[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public class FromCommandIdAttribute : Attribute, IModelNameProvider, IBinderTypeProviderMetadata
{
    public BindingSource BindingSource => BindingSource.Header;

    public string Name => "CommandId";

    public Type BinderType => typeof(GuidHeaderModelBinder);
}

Controller

public async Task<IActionResult> Post(
            [FromCommandId] Guid commandId,
            [FromBody] ...,
            CancellationToken cancellationToken)
{
    ...
}