Example #1
0
        private async Task ProcessRequestAsync(HttpContextBase context)
        {
            var diagnosticService = _configuration.DiagnosticService;

            await diagnosticService.EmitAsync(
                new HttpEventBuilder(this, HttpEventType.HttpRequestReceived)
            {
                Remote = context.Request.UserHostAddress,
                Uri    = context.Request.Url,
                Method = context.Request.HttpMethod
            }.Build());

            var resourceRequest  = new HttpRequestAdapter(context.Request, context.User);
            var resourceResponse = new HttpResponseAdapter(context.Response);

            try
            {
                await _resourceRouter.Route(resourceRequest, resourceResponse);
            }
            catch (Exception ex)
            {
                var exceptionHandler = new HttpExceptionHandler(resourceRequest, resourceResponse, diagnosticService);
                exceptionHandler.HandleException(ex);
            }

            await diagnosticService.EmitAsync(
                new HttpEventBuilder(this, HttpEventType.HttpRequestReceived)
            {
                Remote = context.Request.UserHostAddress,
                Uri    = context.Request.Url,
                Method = context.Request.HttpMethod,
                Status = context.Response.StatusCode
            }.Build());
        }
Example #2
0
        public async Task ProcessRequestAsync(HttpContextBase context)
        {
            Log.DebugFormat("[Process {0}, Thread {1}, AppDomain {2}]",
                Process.GetCurrentProcess().Id,
                Thread.CurrentThread.ManagedThreadId,
                AppDomain.CurrentDomain.Id);

            Log.DebugFormat("Processing {0} request for resource {1} (HTTP handler instance: {2})...",
                context.Request.HttpMethod, context.Request.Url, _instanceId);
            var resourceRequest = new HttpRequestAdapter(context.Request, context.User);
            var resourceResponse = new HttpResponseAdapter(context.Response);
            try
            {
                var resourceRouter = await BusManager.SingletonInstance.GetResourceRouter();
                await resourceRouter.Route(resourceRequest, resourceResponse);
                Log.DebugFormat("Processing {0} request for resource {1} (HTTP handler instance: {2})...",
                    context.Request.HttpMethod, context.Request.Url, _instanceId);
            }
            catch (Exception ex)
            {
                var exceptionHandler = new HttpExceptionHandler(resourceRequest, resourceResponse, Log);
                exceptionHandler.HandleException(ex);
            }
        }