public InteractiveModule(IInteractiveDiagnostics interactiveDiagnostics) :base ("/interactive") { this.interactiveDiagnostics = interactiveDiagnostics; Get["/"] = _ => { return View["InteractiveDiagnostics"]; }; Get["/providers"] = _ => { var providers = this.interactiveDiagnostics .AvailableDiagnostics .Select(p => new { p.Name, p.Description, Type = p.GetType().Name, p.GetType().Namespace, Assembly = p.GetType().Assembly.GetName().Name }) .ToArray(); return this.Response.AsJson(providers); }; Get["/providers/{providerName}"] = ctx => { var providerName = HttpUtility.UrlDecode((string)ctx.providerName); var diagnostic = this.interactiveDiagnostics.GetDiagnostic(providerName); if (diagnostic == null) { return HttpStatusCode.NotFound; } var methods = diagnostic.Methods .Select(m => new { m.MethodName, ReturnType = m.ReturnType.ToString(), m.Description, Arguments = m.Arguments.Select(a => new { ArgumentName = a.Item1, ArgumentType = a.Item2.ToString() }) }) .ToArray(); return this.Response.AsJson(methods); }; Get["/providers/{providerName}/{methodName}"] = ctx => { var providerName = HttpUtility.UrlDecode((string)ctx.providerName); var methodName = HttpUtility.UrlDecode((string)ctx.methodName); var method = this.interactiveDiagnostics.GetMethod(providerName, methodName); if (method == null) { return HttpStatusCode.NotFound; } object[] arguments = GetArguments(method, this.Request.Query); return this.Response.AsJson(new { Result = this.interactiveDiagnostics.ExecuteDiagnostic(method, arguments) }); }; Get["/templates/{providerName}/{methodName}"] = ctx => { var providerName = HttpUtility.UrlDecode((string)ctx.providerName); var methodName = HttpUtility.UrlDecode((string)ctx.methodName); var method = this.interactiveDiagnostics.GetMethod(providerName, methodName); if (method == null) { return HttpStatusCode.NotFound; } var template = this.interactiveDiagnostics.GetTemplate(method); if (template == null) { return HttpStatusCode.NotFound; } return template; }; }
public InteractiveModule(IRequestTracing sessionProvider, IInteractiveDiagnostics interactiveDiagnostics) : base("/interactive") { this.interactiveDiagnostics = interactiveDiagnostics; Get["/"] = _ => View["InteractiveDiagnostics"]; Get["/providers"] = _ => { var providers = this.interactiveDiagnostics .AvailableDiagnostics .Select(p => new { p.Name, p.Description, Type = p.GetType().Name, p.GetType().Namespace, Assembly = p.GetType().Assembly.GetName().Name }) .ToArray(); return(Response.AsJson(providers)); }; Get["/providers/{providerName}"] = ctx => { InteractiveDiagnostic diagnostic = this.interactiveDiagnostics.GetDiagnostic(ctx.providerName); if (diagnostic == null) { return(HttpStatusCode.NotFound); } var methods = diagnostic.Methods .Select(m => new { m.MethodName, ReturnType = m.ReturnType.ToString(), m.Description, Arguments = m.Arguments.Select(a => new { ArgumentName = a.Item1, ArgumentType = a.Item2.ToString() }) }) .ToArray(); return(Response.AsJson(methods)); }; Get["/providers/{providerName}/{methodName}"] = ctx => { InteractiveDiagnosticMethod method = this.interactiveDiagnostics.GetMethod(ctx.providerName, ctx.methodName); if (method == null) { return(HttpStatusCode.NotFound); } object[] arguments = this.GetArguments(method, this.Request.Query); return(Response.AsJson(new { Result = this.interactiveDiagnostics.ExecuteDiagnostic(method, arguments) })); }; Get["/templates/{providerName}/{methodName}"] = ctx => { InteractiveDiagnosticMethod method = this.interactiveDiagnostics.GetMethod(ctx.providerName, ctx.methodName); if (method == null) { return(HttpStatusCode.NotFound); } var template = this.interactiveDiagnostics.GetTemplate(method); if (template == null) { return(HttpStatusCode.NotFound); } return(template); }; }
/// <summary> /// Initializes a new instance of the <see cref="InteractiveModule"/> class, with /// the provided <paramref name="interactiveDiagnostics"/>. /// </summary> /// <param name="interactiveDiagnostics">The interactive diagnostics.</param> public InteractiveModule(IInteractiveDiagnostics interactiveDiagnostics) : base("/interactive") { this.interactiveDiagnostics = interactiveDiagnostics; Get("/", _ => { return(View["InteractiveDiagnostics"]); }); Get("/providers", _ => { var providers = this.interactiveDiagnostics .AvailableDiagnostics .Select(p => new { p.Name, p.Description, Type = p.GetType().Name, p.GetType().Namespace, Assembly = p.GetType().GetTypeInfo().Assembly.GetName().Name }) .ToArray(); return(this.Response.AsJson(providers)); }); Get("/providers/{providerName}", ctx => { var providerName = HttpUtility.UrlDecode((string)ctx.providerName); var diagnostic = this.interactiveDiagnostics.GetDiagnostic(providerName); if (diagnostic == null) { return(HttpStatusCode.NotFound); } var methods = diagnostic.Methods .Select(m => new { m.MethodName, ReturnType = m.ReturnType.ToString(), m.Description, Arguments = m.Arguments.Select(a => new { ArgumentName = a.Item1, ArgumentType = a.Item2.ToString() }) }) .ToArray(); return(this.Response.AsJson(methods)); }); Get("/providers/{providerName}/{methodName}", ctx => { var providerName = HttpUtility.UrlDecode((string)ctx.providerName); var methodName = HttpUtility.UrlDecode((string)ctx.methodName); var method = this.interactiveDiagnostics.GetMethod(providerName, methodName); if (method == null) { return(HttpStatusCode.NotFound); } object[] arguments = GetArguments(method, this.Request.Query); return(this.Response.AsJson(new { Result = this.interactiveDiagnostics.ExecuteDiagnostic(method, arguments) })); }); Get <Response>("/templates/{providerName}/{methodName}", ctx => { var providerName = HttpUtility.UrlDecode((string)ctx.providerName); var methodName = HttpUtility.UrlDecode((string)ctx.methodName); var method = this.interactiveDiagnostics.GetMethod(providerName, methodName); if (method == null) { return(HttpStatusCode.NotFound); } var template = this.interactiveDiagnostics.GetTemplate(method); if (template == null) { return(HttpStatusCode.NotFound); } return(template); }); }