Beispiel #1
0
        /// <inheritdoc/>
        public Task FulfillAsync(
            int?status = default,
            IEnumerable <KeyValuePair <string, string> > headers = default,
            string contentType = default,
            string body        = default,
            byte[] bodyBytes   = default,
            string path        = default)
        {
            var normalized = NormalizeFulfillParameters(status, headers, contentType, body, bodyBytes, path);

            return(_channel.FulfillAsync(normalized));
        }
Beispiel #2
0
        public Task FulfillAsync(RouteFulfillOptions options = default)
        {
            options ??= new RouteFulfillOptions();
            var normalized = NormalizeFulfillParameters(
                options.Status,
                options.Headers,
                options.ContentType,
                options.Body,
                options.BodyBytes,
                options.Path);

            return(RaceWithPageCloseAsync(_channel.FulfillAsync(normalized)));
        }
Beispiel #3
0
        /// <summary>
        /// Fulfills route's request with given response.
        /// </summary>
        /// <param name="status">Status code of the response.</param>
        /// <param name="body">Optional response body as text.</param>
        /// <param name="headers">Optional response headers.</param>
        /// <param name="contentType">If set, equals to setting Content-Type response header.</param>
        /// <param name="bodyContent">Optional response body as binary.</param>
        /// <param name="path">Optional file path to respond with. The content type will be inferred from file extension.
        /// If path is a relative path, then it is resolved relative to current working directory.</param>
        /// <returns>A <see cref="Task"/> that completes when the message was sent.</returns>
        public Task FulfillAsync(
            HttpStatusCode?status = null,
            string body           = null,
            Dictionary <string, string> headers = null,
            string contentType = null,
            byte[] bodyContent = null,
            string path        = null)
        {
#pragma warning disable CA1062 // Validate arguments of public methods
            var normalized = NormalizeFulfillParameters(status, headers, contentType, body, bodyContent, path);
#pragma warning restore CA1062 // Validate arguments of public methods
            return(_channel.FulfillAsync(normalized));
        }