Exemple #1
0
 /// <summary> Adds middleware for Altair GraphQL UI using the specified options. </summary>
 /// <param name="app"> <see cref="IApplicationBuilder"/> to configure an application's request pipeline. </param>
 /// <param name="options"> Options to customize <see cref="AltairMiddleware"/>. If not set, then the default values will be used. </param>
 /// <param name="path">The path to the Altair GraphQL UI endpoint which defaults to '/ui/altair'</param>
 /// <returns> The reference to provided <paramref name="app"/> instance. </returns>
 public static IApplicationBuilder UseGraphQLAltair(this IApplicationBuilder app, AltairOptions options, string path = "/ui/altair")
 {
     return(app.UseWhen(
                context => HttpMethods.IsGet(context.Request.Method) && !context.WebSockets.IsWebSocketRequest &&
                context.Request.Path.StartsWithSegments(path, out var remaining) && string.IsNullOrEmpty(remaining),
                b => b.UseMiddleware <AltairMiddleware>(options ?? new AltairOptions())));
 }
Exemple #2
0
        /// <summary>
        /// Add the Altair middleware to the HTTP request pipeline
        /// </summary>
        /// <param name="endpoints">Defines a contract for a route builder in an application. A route builder specifies the routes for an application.</param>
        /// <param name="options">Options to customize <see cref="AltairMiddleware"/>. If not set, then the default values will be used.</param>
        /// <param name="pattern">The route pattern.</param>
        /// <returns>The <see cref="IApplicationBuilder"/> received as parameter</returns>
        public static AltairEndpointConventionBuilder MapGraphQLAltair(this IEndpointRouteBuilder endpoints, AltairOptions options, string pattern = "ui/altair")
        {
            if (endpoints == null)
            {
                throw new ArgumentNullException(nameof(endpoints));
            }

            var requestDelegate = endpoints.CreateApplicationBuilder().UseMiddleware <AltairMiddleware>(options ?? new AltairOptions()).Build();

            return(new AltairEndpointConventionBuilder(endpoints.Map(pattern, requestDelegate).WithDisplayName("GraphQL Altair")));
        }
Exemple #3
0
 public AltairPageModel(AltairOptions options)
 {
     _options = options;
 }
 public AltairMiddleware(RequestDelegate next, AltairOptions options)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
 }