Beispiel #1
0
        public void Handle(IContext context)
        {
            var req = new SimpleServerRequest(context.Request, new SimpleServerConnection(context.Connection), this);
            var res = new SimpleServerResponse(req, ((HttpContext)context).Response);
            var ctx = new SimpleServerContext()
            {
                Request = req, Response = res, Connection = req.Connection, Handled = false
            };
            var handler = Handlers.FirstOrDefault(x => x.CanHandle(req));

            if (handler == null)
            {
                ErrorManager.Error404(ctx);
            }
            else
            {
                handler.Handle(ctx);
            }
        }
Beispiel #2
0
        private void SrvOnOnError(object sender, ErrorEventArgs e)
        {
            Log.Error("" + (int)e.Type + " " + e.Type + ": " + e.CurrentError);
            var req = new SimpleServerRequest(e.Context.Request, new SimpleServerConnection(e.Context.Connection),
                                              this);
            var res = new SimpleServerResponse(req, ((HttpContext)e.Context).Response);
            var ctx = new SimpleServerContext()
            {
                Request = req, Response = res, Connection = req.Connection, Handled = false
            };

            if (e.Type == ErrorType.HandlerNotFound)
            {
                ErrorManager.Error404(ctx);
            }
            else
            {
                ErrorManager.Error(ctx, (int)e.Type, e.Type.ToString(), e.CurrentError.ToString());
            }
        }