* Now the rest handlers try to match path as close as possibly, so it's possible to add handlers for just a beginning of a path.
parent
514a323056
commit
30c5be3704
|
@ -35,8 +35,8 @@ namespace OpenSim.CAPS
|
||||||
server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
|
server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
|
||||||
server.AddRestHandler("POST", "/Admin/Login", PostLogin );
|
server.AddRestHandler("POST", "/Admin/Login", PostLogin );
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetWelcomePage( string request )
|
private string GetWelcomePage(string request, string path)
|
||||||
{
|
{
|
||||||
string responseString;
|
string responseString;
|
||||||
responseString = "Welcome to the OpenSim Admin Page";
|
responseString = "Welcome to the OpenSim Admin Page";
|
||||||
|
@ -44,7 +44,7 @@ namespace OpenSim.CAPS
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PostLogin(string requestBody)
|
private string PostLogin(string requestBody, string path)
|
||||||
{
|
{
|
||||||
string responseString;
|
string responseString;
|
||||||
// Console.WriteLine(requestBody);
|
// Console.WriteLine(requestBody);
|
||||||
|
@ -61,7 +61,7 @@ namespace OpenSim.CAPS
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PostNewAccount(string requestBody)
|
private string PostNewAccount(string requestBody, string path)
|
||||||
{
|
{
|
||||||
string responseString;
|
string responseString;
|
||||||
string firstName = "";
|
string firstName = "";
|
||||||
|
@ -110,7 +110,7 @@ namespace OpenSim.CAPS
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetConnectedClientsPage( string request )
|
private string GetConnectedClientsPage(string request, string path)
|
||||||
{
|
{
|
||||||
string responseString;
|
string responseString;
|
||||||
responseString = " <p> Listing connected Clients </p>";
|
responseString = " <p> Listing connected Clients </p>";
|
||||||
|
@ -128,7 +128,7 @@ namespace OpenSim.CAPS
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetAccountsPage( string request )
|
private string GetAccountsPage(string request, string path)
|
||||||
{
|
{
|
||||||
string responseString;
|
string responseString;
|
||||||
responseString = "<p> Account management </p>";
|
responseString = "<p> Account management </p>";
|
||||||
|
@ -138,7 +138,7 @@ namespace OpenSim.CAPS
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetAdminPage( string request )
|
private string GetAdminPage(string request, string path)
|
||||||
{
|
{
|
||||||
return AdminPage;
|
return AdminPage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,23 @@ namespace OpenSim.Servers
|
||||||
string response;
|
string response;
|
||||||
RestMethod handler;
|
RestMethod handler;
|
||||||
|
|
||||||
string methodKey = String.Format("{0}: {1}", method, path);
|
string requestKey = String.Format("{0}: {1}", method, path);
|
||||||
|
|
||||||
if (m_restHandlers.TryGetValue(methodKey, out handler))
|
string bestMatch = String.Empty;
|
||||||
|
foreach( string currentKey in m_restHandlers.Keys )
|
||||||
{
|
{
|
||||||
response = handler(request);
|
if( requestKey.StartsWith( currentKey ))
|
||||||
|
{
|
||||||
|
if(currentKey.Length > bestMatch.Length )
|
||||||
|
{
|
||||||
|
bestMatch = currentKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_restHandlers.TryGetValue(bestMatch, out handler))
|
||||||
|
{
|
||||||
|
response = handler(request, path);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -4,5 +4,5 @@ using System.Text;
|
||||||
|
|
||||||
namespace OpenSim.CAPS
|
namespace OpenSim.CAPS
|
||||||
{
|
{
|
||||||
public delegate string RestMethod( string request );
|
public delegate string RestMethod( string request, string path );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue