I have a basic endpoint:
[HttpGet]
[MyAttribute]
public string Get()
{
// Do stuff
}
And a basic middleware:
public class MyMiddleware : IMiddleware
{
public Task InvokeAsync(HttpContext context, RequestDelegate next)
{
var endpoint = context.GetEndpoint();
var metadata = endpoint.Metadata;
if (metadata.GetMetadata<MyAttribute>() != null)
{
// Do stuff
}
return next(context);
}
}
I would like to have the middleware be contextually aware of the [MyAttribute]
but it does not show up in the endpoint metadata. How can I achieve this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…