/// <summary> /// Extension method to use the JsonRpc router in the Asp.Net pipeline /// </summary> /// <param name="app"><see cref="IApplicationBuilder"/> that is supplied by Asp.Net</param> /// <param name="routeProvider">Action to configure route provider</param> /// <returns><see cref="IApplicationBuilder"/> that includes the Basic auth middleware</returns> public static IApplicationBuilder UseJsonRpc(this IApplicationBuilder app, IRpcRouteProvider routeProvider) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (routeProvider == null) { throw new ArgumentNullException(nameof(routeProvider)); } RpcRouter router = ActivatorUtilities.CreateInstance <RpcRouter>(app.ApplicationServices, routeProvider); return(app.UseRouter(router)); }
/// <summary> /// Extension method to use the JsonRpc router in the Asp.Net pipeline /// </summary> /// <param name="app"><see cref="IApplicationBuilder"/> that is supplied by Asp.Net</param> /// <param name="configureOptions">Action to configure auto route provider options</param> /// <returns><see cref="IApplicationBuilder"/> that includes the Basic auth middleware</returns> public static IApplicationBuilder UseJsonRpc(this IApplicationBuilder app, Action <RpcAutoRoutingOptions> configureOptions = null) { if (app == null) { throw new ArgumentNullException(nameof(app)); } var options = new RpcAutoRoutingOptions(); configureOptions?.Invoke(options); IRpcRouteProvider routeProvider = new RpcAutoRouteProvider(options); RpcRouter router = ActivatorUtilities.CreateInstance <RpcRouter>(app.ApplicationServices, routeProvider); return(app.UseRouter(router)); }