title: asp.net core check route attribute in middleware
body: <p>I'm trying to build some ASP.Net core middleware. </p>
  
  <p>It needs see if the current route is marked as [Authorize]. </p>
  
  <p>eg:</p>
  
  <pre><code>public async Task Invoke(HttpContext context)
  {
      if(context.Request.Path.Value.StartsWith("/api"))
      {
          // check if route is marked as [Authorize]
          // and then do some logic
      }
  
      await _next.Invoke(context);
  }
  </code></pre>
  
  <p>Does anyone know how this could be achieved or if it's even possible? </p>
  
  <p>If not, what would be a good alternative approach?</p>