예제 #1
0
        /// <summary>
        /// Configures a HTTP host by using the specified <paramref name="options"/>.
        /// </summary>
        /// <param name="builder"><see cref="IMassTransitBuilder"/></param>.
        /// <param name="options"><see cref="HttpOptions"/></param>
        /// <param name="hostConfigurator">The configuration callback to configure the HTTP bus.</param>
        public static void UseHttp(this IMassTransitBuilder builder, HttpOptions options, Action <IHttpHostBuilder> hostConfigurator = null)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var method = HttpHostBuilder.ToHttpMethod(options.Method);

            UseHttp(builder, options.ConnectionName, options.Scheme, options.Host, options.Port, method, hostConfigurator);
        }
예제 #2
0
        /// <summary>
        /// Configures a HTTP host by using the specified application configuration.
        /// </summary>
        /// <param name="builder"><see cref="IMassTransitBuilder"/></param>.
        /// <param name="configuration">The <see cref="IConfiguration"/> being bound.</param>
        /// <param name="hostConfigurator">The configuration callback to configure the HTTP bus.</param>
        public static void UseHttp(this IMassTransitBuilder builder, IConfiguration configuration, Action <IHttpHostBuilder> hostConfigurator = null)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var connectionName = configuration["ConnectionName"];
            var hostBuilder    = new HttpHostBuilder(builder.Services, connectionName, configuration);

            hostConfigurator?.Invoke(hostBuilder);
        }
예제 #3
0
        /// <summary>
        /// Configures a HTTP host using a MassTransit host address.
        /// </summary>
        /// <param name="builder"><see cref="IMassTransitBuilder"/></param>
        /// <param name="connectionName">The client-provided connection name.</param>
        /// <param name="scheme">Specifies the HTTP or HTTPS scheme.</param>
        /// <param name="host">The HTTP host to connect to (should be a valid hostname).</param>
        /// <param name="port">The HTTP port to connect to.</param>
        /// <param name="method">The HTTP method (i.e. verb) to use, defaults to POST.</param>
        /// <param name="hostConfigurator">The configuration callback to configure the HTTP bus.</param>
        public static void UseHttp(this IMassTransitBuilder builder, string connectionName, string scheme, string host, int port, HttpMethod method, Action <IHttpHostBuilder> hostConfigurator = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (scheme == null)
            {
                throw new ArgumentNullException(nameof(scheme));
            }
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            var hostBuilder = new HttpHostBuilder(builder.Services, connectionName, scheme, host, port);

            if (method != null)
            {
                hostBuilder.UseMethod(method);
            }

            hostConfigurator?.Invoke(hostBuilder);
        }