diff --git a/Duplicati/Server/WebServer/RESTMethods/Help.cs b/Duplicati/Server/WebServer/RESTMethods/Help.cs index 4a554cf1c..6df741260 100644 --- a/Duplicati/Server/WebServer/RESTMethods/Help.cs +++ b/Duplicati/Server/WebServer/RESTMethods/Help.cs @@ -19,7 +19,6 @@ using System; using System.Linq; using System.Text; using Newtonsoft.Json; namespace Duplicati.Server.WebServer.RESTMethods { public class Help : IRESTMethodGET - { - public void GET(string key, RequestInfo info) { var sb = new StringBuilder(); if (string.IsNullOrWhiteSpace(key)) { foreach(var m in RESTHandler.Modules.Keys.OrderBy(x => x)) { var mod = RESTHandler.Modules[m]; if (mod == this) continue; var desc = mod.GetType().Name; if (mod is IRESTMethodDocumented) desc = ((IRESTMethodDocumented)mod).Description; sb.AppendFormat(ITEM_TEMPLATE, RESTHandler.API_URI_PATH, m, mod.GetType().Name, desc); } var data = Encoding.UTF8.GetBytes(string.Format(TEMPLATE, "API Information", "", sb.ToString())); info.Response.ContentType = "text/html"; info.Response.ContentLength = data.Length; info.Response.Body.Write(data, 0, data.Length); info.Response.Send(); } else { IRESTMethod m; RESTHandler.Modules.TryGetValue(key, out m); if (m == null) { info.Response.Status = System.Net.HttpStatusCode.NotFound; info.Response.Reason = "Module not found"; } else { var desc = ""; if (m is IRESTMethodDocumented) { var doc = m as IRESTMethodDocumented; desc = doc.Description; foreach(var t in doc.Types) sb.AppendFormat(METHOD_TEMPLATE, t.Key, JsonConvert.SerializeObject(t.Value)); //TODO: Format the type } var data = Encoding.UTF8.GetBytes(string.Format(TEMPLATE, m.GetType().Name, desc, sb.ToString())); info.Response.ContentType = "text/html"; info.Response.ContentLength = data.Length; info.Response.Body.Write(data, 0, data.Length); info.Response.Send(); } } } private const string TEMPLATE = @" {0}

{0}

{1}

"; private const string ITEM_TEMPLATE = @"
  • {2}: {3}
  • "; private const string METHOD_TEMPLATE = @" {0}:
    {1}
    "; } + { public void GET(string key, RequestInfo info) { var sb = new StringBuilder(); if (string.IsNullOrWhiteSpace(key)) { foreach(var m in RESTHandler.Modules.Keys.OrderBy(x => x)) { var mod = RESTHandler.Modules[m]; if (mod == this) continue; var desc = mod.GetType().Name; if (mod is IRESTMethodDocumented) desc = ((IRESTMethodDocumented)mod).Description; sb.AppendFormat(ITEM_TEMPLATE, RESTHandler.API_URI_PATH, m, mod.GetType().Name, desc); } var data = Encoding.UTF8.GetBytes(string.Format(TEMPLATE, "API Information", "", sb.ToString())); info.Response.ContentType = "text/html"; info.Response.ContentLength = data.Length; info.Response.Body.Write(data, 0, data.Length); info.Response.Send(); } else { IRESTMethod m; RESTHandler.Modules.TryGetValue(key, out m); if (m == null) { info.Response.Status = System.Net.HttpStatusCode.NotFound; info.Response.Reason = "Module not found"; } else { var desc = ""; if (m is IRESTMethodDocumented) { var doc = m as IRESTMethodDocumented; desc = doc.Description; foreach(var t in doc.Types) sb.AppendFormat(METHOD_TEMPLATE, t.Key, JsonConvert.SerializeObject(t.Value)); //TODO: Format the type } var data = Encoding.UTF8.GetBytes(string.Format(TEMPLATE, m.GetType().Name, desc, sb.ToString())); info.Response.ContentType = "text/html"; info.Response.ContentLength = data.Length; info.Response.Body.Write(data, 0, data.Length); info.Response.Send(); } } } private const string TEMPLATE = @" {0}

    {0}

    {1}

    "; private const string ITEM_TEMPLATE = @"
  • {2}: {3}
  • "; private const string METHOD_TEMPLATE = @" {0}:
    {1}
    "; } }