Skip to main content

Endpoint samples

The runnable host has four startup choices. Select one near the top of Program.cs, then run:

dotnet run --project endpoints/samples/Valiant.Endpoints.AspNetCore.Samples
Type? startup;

//startup = typeof(Samples.Basic.Startup);
//startup = typeof(Samples.Configuration.Startup);
//startup = typeof(Samples.ConditionalRegistration.Startup);
startup = typeof(Samples.QueryBinding.Startup);

Endpoint discovery is assembly-wide. Every attributed endpoint in the sample project contributes generated registration code; the selected startup controls the global options and conventions applied when those registrations are mapped.

Available startups

StartupDemonstratesSource
Basic.StartupDefault discovery and mapping for a standalone endpoint and an endpoint groupBasic
Configuration.StartupConfigureEndpointGroup, ConfigureEndpoint, and descriptor-based guards using group and endpoint metadataConfiguration
ConditionalRegistration.StartupIndependent MapEndpointGroupsWhen and MapEndpointWhen policies, including allowed and rejected registrationsConditionalRegistration
QueryBinding.StartupGenerated query binding for arrays, objects, JSON values, and supported query formatsQueryBinding

Every startup registers and maps the generated route plan through AddValiantEndpoints() and MapValiantEndpoints().

Configuration hooks

The configuration startup applies one convention to both endpoints in its group and a second convention only to SelectedEndpoint:

RouteX-Valiant-GroupX-Valiant-Endpoint
/configuration/selectedConfigurationEndpointGroupSelectedEndpoint
/configuration/group-onlyConfigurationEndpointGroupnot present

The hook receives the builder returned by the user-authored mapping method and its generated registration descriptor. See Groups and conventions for the complete mapping sequence.

Conditional registration

The conditional startup exercises positive and negative cases for both predicates:

RouteStatusPolicy demonstrated
/conditional/groups/allowed/hello200group allowed
/conditional/groups/blocked/hello404group rejected
/conditional/endpoints/allowed200standalone endpoint allowed
/conditional/endpoints/blocked404standalone endpoint rejected

Rejecting a group skips its child registrations, so MapEndpointWhen is not evaluated for those children. These are startup-time registration decisions, not request-time feature checks. See Conditional registration for descriptor details and precedence.

Query binding

The query-binding startup opts the compilation into generated binding:

services.AddValiantEndpoints(options =>
{
options.QueryParameters.EnableBinding = true;
});

Its /query/* routes cover array and object formats, direct JSON query values, and an endpoint that explicitly disables JSON parsing. See Request binding and the query parameter reference before choosing a binding shape.