Esempio n. 1
0
        /// <summary>Begins execution of the specified request context</summary>
        /// <returns>Returns an IAsyncController instance.</returns>
        /// <param name="requestContext">The request context.</param>
        /// <param name="callback">The asynchronous callback.</param>
        /// <param name="state">The state.</param>
        protected override IAsyncResult BeginExecute(
            RequestContext requestContext,
            AsyncCallback callback,
            object state)
        {
            controllerBenchmark = benchmarkHelper.Create(requestContext.HttpContext.Request.RawUrl);

            return(base.BeginExecute(requestContext, callback, state));
        }
Esempio n. 2
0
 /// <summary>Executes asynchronously a single HTTP operation.</summary>
 /// <returns>The newly started task.</returns>
 /// <param name="controllerContext">The controller context for a single HTTP operation.</param>
 /// <param name="cancellationToken">The cancellation token assigned for the HTTP operation.</param>
 public override Task <HttpResponseMessage> ExecuteAsync(
     HttpControllerContext controllerContext,
     CancellationToken cancellationToken)
 {
     using (benchmarkHelper.Create(controllerContext.Request.RequestUri))
     {
         return(base.ExecuteAsync(controllerContext, cancellationToken));
     }
 }
Esempio n. 3
0
        /// <summary>
        ///     Sends an HTTP DELETE request to the given uri.
        /// </summary>
        /// <typeparam name="T">The response type.</typeparam>
        /// <param name="uri">The URI.</param>
        /// <param name="username">The username.</param>
        /// <returns>The response object.</returns>
        protected async Task <T> Delete <T>(string uri, string username)
            where T : BaseResponse
        {
            var response = (T)Activator.CreateInstance(typeof(T));

            HttpResponseMessage httpResponse;

            using (benchmarkHelper.Create(uri))
            {
                httpResponse = await client.DeleteAsync(uri);
            }

            if (!httpResponse.IsSuccessStatusCode)
            {
                var err = errorHelper.Create(GetHttpError(httpResponse), username, GetType(), "Delete");
                response.AddError(err);

                return(response);
            }

            response = await httpResponse.Content.ReadAsAsync <T>();

            return(response);
        }