TSHOCKPLUGINS-2 #resolve #comment Added.
This commit is contained in:
parent
5d61a56fcd
commit
264e633202
1 changed files with 34 additions and 21 deletions
|
|
@ -128,31 +128,44 @@ namespace Rests
|
||||||
|
|
||||||
protected virtual object ProcessRequest(object sender, RequestEventArgs e)
|
protected virtual object ProcessRequest(object sender, RequestEventArgs e)
|
||||||
{
|
{
|
||||||
var uri = e.Request.Uri.AbsolutePath;
|
try
|
||||||
uri = uri.TrimEnd('/');
|
|
||||||
|
|
||||||
foreach (var com in commands)
|
|
||||||
{
|
{
|
||||||
var verbs = new RestVerbs();
|
var uri = e.Request.Uri.AbsolutePath;
|
||||||
if (com.HasVerbs)
|
uri = uri.TrimEnd('/');
|
||||||
{
|
|
||||||
var match = Regex.Match(uri, com.UriVerbMatch);
|
|
||||||
if (!match.Success)
|
|
||||||
continue;
|
|
||||||
if ((match.Groups.Count - 1) != com.UriVerbs.Length)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (int i = 0; i < com.UriVerbs.Length; i++)
|
foreach (var com in commands)
|
||||||
verbs.Add(com.UriVerbs[i], match.Groups[i + 1].Value);
|
|
||||||
}
|
|
||||||
else if (com.UriTemplate.ToLower() != uri.ToLower())
|
|
||||||
{
|
{
|
||||||
continue;
|
var verbs = new RestVerbs();
|
||||||
}
|
if (com.HasVerbs)
|
||||||
|
{
|
||||||
|
var match = Regex.Match(uri, com.UriVerbMatch);
|
||||||
|
if (!match.Success)
|
||||||
|
continue;
|
||||||
|
if ((match.Groups.Count - 1) != com.UriVerbs.Length)
|
||||||
|
continue;
|
||||||
|
|
||||||
var obj = ExecuteCommand(com, verbs, e.Request.Parameters);
|
for (int i = 0; i < com.UriVerbs.Length; i++)
|
||||||
if (obj != null)
|
verbs.Add(com.UriVerbs[i], match.Groups[i + 1].Value);
|
||||||
return obj;
|
}
|
||||||
|
else if (com.UriTemplate.ToLower() != uri.ToLower())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var obj = ExecuteCommand(com, verbs, e.Request.Parameters);
|
||||||
|
if (obj != null)
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
return new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{"status", "500"},
|
||||||
|
{"error", "Internal server error."},
|
||||||
|
{"errormsg", exception.Message},
|
||||||
|
{"stacktrace", exception.StackTrace},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return new Dictionary<string, string>
|
return new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue