You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been searching for a few days for guides as to implementing my own Endpoints via an EndpointDataSource implementation. Where I'm struggling the most is finding information on which metadata objects are used for Authorization/Authentication, HttpMethods, Host, etc. As well as there is seemingly only the source code for YARP and this blog to go off of for seeing how to implement EndpointDataSource.
But am wondering if there are any plans to more formally document how someone might go about creating an endpoint implementation.
I understand that in the following example I would miss out on any "minimal api" specific functionality but believe I should be able to augment this RouteEndpoint, (or a custom Endpoint and Matcher? / IRouter?) to plug into other middleware functionality like Auth.
usingMicrosoft.AspNetCore.Routing.Patterns;varbuilder=WebApplication.CreateBuilder(args);varapp=builder.Build();// Step 1: Create a RequestDelegate (handler)RequestDelegatehandler=async(HttpContextcontext)=>{awaitcontext.Response.WriteAsync("Hello from custom RouteEndpoint!");};// Step 2: Create a RouteEndpoint manuallyvarrouteEndpoint=newRouteEndpoint(requestDelegate:handler,routePattern:RoutePatternFactory.Parse("/"),order:0,metadata:newEndpointMetadataCollection(),displayName:"Custom RouteEndpoint");// Step 3: Create an EndpointDataSource that holds custom endpointsvardataSource=newDefaultEndpointDataSource(routeEndpoint);// could create a custom one of these// Step 4: Register middleware to use custom endpoint resolutionapp.UseRouting();((IEndpointRouteBuilder)app).DataSources.Add(dataSource);// Step 5: Start the appapp.Run();
Mostly I'm looking for:
How can I know when to do this and with what classes/instances?
if(hostsis not null&&hosts.Count!=0){endpointBuilder.Metadata.Add(newHostAttribute(hosts.ToArray()));}
Are there any plans to break out the Metadata.Add calls into ConventionBuilders for each concern? So that someone building a library could call
endpointBuilder.ApplyHostsMetadata(hosts);
My goal: register endpoints based on a custom spec. similar to YARP.
My concern: I use yarp's code as a guide but wont be able to know if the Metadata objects ever have breaking changes.
My hope: Explicit docs, guides, or public API's that guide a developer to success by default.
I am willing to collaborate/contribute as I can. If there were any guidance on this I'd be happy to pick it up to build a proposal but I'm starting somewhat in the dark based on all information I could find.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been searching for a few days for guides as to implementing my own Endpoints via an
EndpointDataSource
implementation. Where I'm struggling the most is finding information on which metadata objects are used for Authorization/Authentication, HttpMethods, Host, etc. As well as there is seemingly only the source code for YARP and this blog to go off of for seeing how to implementEndpointDataSource
.I can see them used in YARP:
EndpointDataSource
Metadata Add
But am wondering if there are any plans to more formally document how someone might go about creating an endpoint implementation.
I understand that in the following example I would miss out on any "minimal api" specific functionality but believe I should be able to augment this RouteEndpoint, (or a custom Endpoint and Matcher? / IRouter?) to plug into other middleware functionality like Auth.
Mostly I'm looking for:
How can I know when to do this and with what classes/instances?
Are there any plans to break out the
Metadata.Add
calls intoConventionBuilders
for each concern? So that someone building a library could callMy goal: register endpoints based on a custom spec. similar to YARP.
My concern: I use yarp's code as a guide but wont be able to know if the Metadata objects ever have breaking changes.
My hope: Explicit docs, guides, or public API's that guide a developer to success by default.
I am willing to collaborate/contribute as I can. If there were any guidance on this I'd be happy to pick it up to build a proposal but I'm starting somewhat in the dark based on all information I could find.
Any discussion is welcome. Thanks
Beta Was this translation helpful? Give feedback.
All reactions