Esempio n. 1
0
        public static void UseRouting(this ServerOptions app)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.UseMiddleware(new EndpointRoutingMiddleware());
        }
Esempio n. 2
0
        public static void UseMvc(this ServerOptions app)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.UseMiddleware(new ControllerMiddleware());
        }
        /// <summary>
        /// Captures <see cref="Exception"/> instances from the pipeline and generates error responses.
        /// </summary>
        /// <param name="app">The <see cref="ServerOptions"/> instance this method extends.</param>
        public static void UseDeveloperExceptionPage(this ServerOptions app)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.UseMiddleware(new DeveloperExceptionPageMiddleware());
        }
        public static void UseCustomMiddleware(this ServerOptions option)
        {
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option));
            }

            option.UseMiddleware(new CustomMiddleware());
        }
Esempio n. 5
0
        /// <summary>
        /// Status code middleware with the given options that checks for responses with status codes
        /// between 400 and 599 that do not have a body.
        /// </summary>
        /// <param name="app">The <see cref="ServerOptions"/> instance this method extends.</param>
        public static void UseStatusCodePages(this ServerOptions app)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.UseMiddleware(new StatusCodePagesMiddleware());
        }
Esempio n. 6
0
        /// <summary>
        /// Enables static file serving for the current request path.
        /// </summary>
        /// <param name="server">The <see cref="ServerOptions"/> instance this method extends.</param>
        public static void UseDefaultFiles(this ServerOptions server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            server.UseMiddleware(new DefaultFilesMiddleware());
        }
Esempio n. 7
0
        /// <summary>
        /// Enables static file serving for the current request path.
        /// </summary>
        /// <param name="options">The <see cref="ServerOptions"/> instance this method extends.</param>
        public static void UseStaticFiles(this ServerOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            options.UseMiddleware(new StaticFileMiddleware());
        }
        /// <summary>
        /// Enables resource file serving for the current request path.
        /// </summary>
        /// <param name="app">The <see cref="ServerOptions"/> instance this method extends.</param>
        /// <param name="options">The <see cref="ResourceFileOptions"/> used to configure the middleware.</param>
        public static void UseResourceFiles(this ServerOptions app, ResourceFileOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            app.UseMiddleware(new ResourceFileMiddleware(options));
        }
Esempio n. 9
0
        /// <summary>
        /// Enable authentication capabilities.
        /// </summary>
        /// <param name="app">The <see cref="ServerOptions"/> instance this method extends.</param>
        /// <param name="options">The <see cref="AuthenticationOptions"/> used to configure the middleware.</param>
        public static void UseAuthentication(this ServerOptions app, AuthenticationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            app.UseMiddleware(new AuthenticationMiddleware(options));
        }
Esempio n. 10
0
        public static void UseEndpoints(this ServerOptions app, EndpointRouteAction configure)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            //var endpointRouteBuilder = new EndpointRouteBuilder();
            //configure(endpointRouteBuilder);

            //var routes = (ArrayList)endpointRouteBuilder.DataSources;

            app.UseMiddleware(new EndpointMiddleware());
        }