Esempio n. 1
0
 public HttpContext(Microsoft.AspNet.Http.HttpContext context, ISettings settings)
 {
     _context  = context;
     _request  = new HttpRequest(context.Request, context.GetFeature <Microsoft.AspNet.Http.Features.IHttpConnectionFeature>());
     _response = new HttpResponse(context.Response);
     _settings = settings;
 }
 public HttpContext(Microsoft.AspNet.Http.HttpContext context, ISettings settings)
 {
     _context = context;
     _request = new HttpRequest(context.Request, context.GetFeature<Microsoft.AspNet.Http.Features.IHttpConnectionFeature>());
     _response = new HttpResponse(context.Response);
     _settings = settings;
 }
Esempio n. 3
0
        // TODO: Look at pushing the workings of this into MasterRequestRuntime
        public async Task Invoke(Microsoft.AspNet.Http.HttpContext context)
        {
            var newContext = new HttpContext(context, _settings);

            if (_runtime.Authorized(newContext))
            {
                // TODO: This is the wrong place for this, AgentRuntime isn't garenteed to execute first
                _contextData.Value = new MessageContext {
                    Id = Guid.NewGuid(), Type = "Request"
                };

                await _runtime.Begin(newContext);

                var handler = (IRequestHandler)null;
                if (_runtime.TryGetHandle(newContext, out handler))
                {
                    await handler.Handle(newContext);
                }
                else
                {
                    await _innerNext(context);
                }

                // TODO: This doesn't work correctly :( (headers)
                await _runtime.End(newContext);
            }
            else
            {
                await _innerNext(context);
            }

            /*
             *
             * //TODO: Logic should probably be more like this.
             * //      Problem is that WebCommon shouldn't know about Profile.
             * //      Have to think about this more. Mayber there is a pattern here???
             *
             * var handeled = false;
             *
             * var handler = (IRequestHandler) null;
             * if (_runtime.TryGetHandle(newContext, out handler)
             *  && _runtime.AuthorizedRequest(newContext))  // Is internal Glimpse request
             * {
             *  handeled = true;
             *
             *  await _runtime.HandleBegin(newContext);
             *  await handler.Handle(newContext);
             *  await _runtime.HandleEnd(newContext);
             * }
             * else if (_runtime.IgnoredRequest(newContext)
             * {
             *  handeled = true;
             *
             *  // TODO: This is the wrong place for this, AgentRuntime isn't garenteed to execute first
             *  _contextData.Value = new MessageContext {Id = Guid.NewGuid(), Type = "Request"};
             *
             *  await _runtime.ProfileBegin(newContext);
             *  await handler.Profile(newContext);
             *  await _runtime.ProfileEnd(newContext);
             * }
             *
             * if (!handeled)
             * {
             *  await _innerNext(context);
             * }
             */
        }