/// <summary> /// Constructs the instance of <see cref="ActorDirectCallMiddleware"/>. /// </summary> /// <param name="next">The next request middleware handler.</param> /// <param name="options">The middleware parameters.</param> /// <param name="bigBrother">The telemetry sink.</param> public ActorDirectCallMiddleware(RequestDelegate next, ActorDirectCallOptions options, IBigBrother bigBrother) { _next = next; _options = options; _bigBrother = bigBrother; _actorMethods = new Lazy <Dictionary <string, ActorMethod> >( () => CreateActorMethodsDictionary(GetAssemblies(_options.InterfaceAssemblies))); }
/// <summary> /// Enables handling of HTTP requests which are directly used to /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param> /// <param name="options">The middleware's parameters.</param> /// <returns></returns> public static IApplicationBuilder UseActorDirectCall(this IApplicationBuilder app, ActorDirectCallOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (options.StatelessServiceContext == null) { throw new ArgumentException("The StatelessServiceContext property must not be null", nameof(options)); } if (options.PathPrefix.Value == null) { throw new ArgumentException("The PathPrefix property must not be null", nameof(options)); } if (options.PathPrefix.Value.Length < 2 || options.PathPrefix.Value.EndsWith("/")) { throw new ArgumentException("The value of the PathPrefix property is invalid.", nameof(options)); } return(app.UseMiddleware <ActorDirectCallMiddleware>(options)); }