/// <summary>
        /// Maps the localization clientside provider on specified path.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="path">The path to map on.</param>
        /// <returns>Route builder to support API call chaining</returns>
        /// <exception cref="ArgumentNullException">path</exception>
        public static IRouteBuilder MapDbLocalizationClientsideProvider(this IRouteBuilder builder, string path = "/jsl10n")
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            ClientsideConfigurationContext.SetRootPath(path);

            builder.MapMiddlewareRoute(path + "/{*remaining}", b => b.UseMiddleware <RequestHandler>());

            return(builder);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Use this method if you are relying on ASP.NET Core EndpointRouting
        /// </summary>
        /// <param name="builder">EndpointRoute builder</param>
        /// <param name="path">Path on which you want to map client-side provider</param>
        /// <returns>The same EndpointRoute builder to support API chaining</returns>
        /// <exception cref="ArgumentNullException">If you gave me empty path to map on, nothing else to do here as just throw up</exception>
        public static IEndpointRouteBuilder MapDbLocalizationClientsideProvider(
            this IEndpointRouteBuilder builder,
            string path = "/jsl10n")
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            ClientsideConfigurationContext.SetRootPath(path);

            var pipeline = builder.CreateApplicationBuilder()
                           .UseMiddleware <RequestHandler>()
                           .Build();

            builder.Map(ClientsideConfigurationContext.RootPath + "/{*remaining}", pipeline);

            return(builder);
        }