public ApiAuthorizedMiddleware(RequestDelegate next, IRouter router)
            : this(next, null, router)
        {
            ApiAuthorizedOptions obj = new ApiAuthorizedOptions();

            obj.isWeb     = false;
            obj.loginUrl  = "";
            this._options = obj;
        }
        public ApiAuthorizedMiddleware(RequestDelegate next, IOptions <ApiAuthorizedOptions> options, IRouter router)
        {
            this._next    = next;
            this._options = options.Value;

            _routeMatcher = new RouteMatcher();



            this._router = router;
        }
Example #3
0
        public static IApplicationBuilder UseApiAuthorized(this IApplicationBuilder builder, ApiAuthorizedOptions options, Action <IRouteBuilder> configureRoutes)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            var routes = new RouteBuilder(builder)
            {
                DefaultHandler = builder.ApplicationServices.GetRequiredService <MvcRouteHandler>(),
            };

            configureRoutes(routes);
            routes.Routes.Insert(0, AttributeRouting.CreateAttributeMegaRoute(builder.ApplicationServices));
            var router = routes.Build();

            return(builder.UseMiddleware <ApiAuthorizedMiddleware>(Options.Create(options), router));
        }