private void Execute() { step = PipelineStep.WaitingForEnd; context = new Context(transaction); var handler = application.Routes.Find(transaction.Request); PipePreProcessTarget((newHandler) => { if (newHandler != handler) { handler = newHandler; } }); if (handler == null) { context.Response.StatusCode = 404; context.Response.End(application.Get404Response()); return; } context.Response.StatusCode = 200; Error.Log.Call<System.Exception>(() => handler.Invoke(application, context), e => { Console.Error.WriteLine("Exception in transaction handler:"); Console.Error.WriteLine(e); context.Response.StatusCode = 500; context.Response.End(application.Get500Response()); // // TODO: Maybe the cleanest thing to do is // have a HandleError, HandleException thing // on HttpTransaction, along with an UnhandledException // method/event on ManosModule. // // end = true; }); PipePostProcessTarget(handler); if (context.Response.StatusCode == 404) { step = PipelineStep.WaitingForEnd; context.Response.End(); return; } }
public static void RenderTemplate(Context context, string template, object data) { Engine.RenderToStream (template, context.Response.Writer, data); }