public MissionControlMiddleware(RequestDelegate next,
                                        McOptions options,
                                        IDispatcher dispatcher,
                                        OutputWriter outputWriter,
                                        ILogger <MissionControlMiddleware> logger)
        {
            _next = next;

            if (options.Authentication == null)
            {
                throw new ArgumentNullException(nameof(options.Authentication), "Request authentication nor provided");
            }

            _options   = options;
            _logger    = logger;
            _urlPrefix = new PathString(options.Url);


            var assembly = this.GetType().GetTypeInfo().Assembly;

            _routes = new List <Route>
            {
                new StaticContentRoute(assembly),
                new DefaultIndexRoute(assembly),
                new CommandsRoute(dispatcher, outputWriter)
            };
        }
예제 #2
0
        /// <summary>
        /// Adds MissionControl middleware on configured console endpoint.
        /// </summary>
        /// <param name="configuration">Optional configuration settings. Use this to configure console endpoint (default is /mc) and authentication</param>
        public static IApplicationBuilder UseMissingControl(this IApplicationBuilder builder, Action <McOptions> configuration = null)
        {
            var options = new McOptions();

            configuration?.Invoke(options);

            return(builder.UseMiddleware <MissionControlMiddleware>(options));
        }