Example #1
0
        public void Proceed(IInvocation invocation)
        {
            var baseUri    = new Uri(ServiceInformation.BaseUrl);
            var uriBuilder = new UriBuilder(new Uri(baseUri, _targetMethodInfo.Url));

            var parameters = ParametersUtils.ExtractHttpRequestParameters(invocation.Arguments, _targetMethodInfo.MethodInfo);

            // add query params
            uriBuilder.AddQueryParameters(parameters.QueryParameters);

            var headers = CombineParamHeadersWithGlobalHeaders(Headers, parameters.HeadersParameters);

            var url = uriBuilder.ToString();
            var req = new InvokeHttpRequest(url, parameters, _targetMethodInfo.HttpMethod);

            var invocationMethodReturnType = invocation.MethodInvocationTarget.ReturnType;

            if (IsTask(invocationMethodReturnType))
            {
                invocation.InvokeHttpMethodAsync(Serializer, headers, req);
            }
            else
            {
                invocation.InvokeHttpMethod(Serializer, headers, req);
            }
        }