mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 18:25:33 +08:00
* 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.
This commit is contained in:
@@ -35,8 +35,8 @@ namespace OpenSim.CAPS
|
||||
server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
|
||||
server.AddRestHandler("POST", "/Admin/Login", PostLogin );
|
||||
}
|
||||
|
||||
private string GetWelcomePage( string request )
|
||||
|
||||
private string GetWelcomePage(string request, string path)
|
||||
{
|
||||
string responseString;
|
||||
responseString = "Welcome to the OpenSim Admin Page";
|
||||
@@ -44,7 +44,7 @@ namespace OpenSim.CAPS
|
||||
return responseString;
|
||||
}
|
||||
|
||||
private string PostLogin(string requestBody)
|
||||
private string PostLogin(string requestBody, string path)
|
||||
{
|
||||
string responseString;
|
||||
// Console.WriteLine(requestBody);
|
||||
@@ -61,7 +61,7 @@ namespace OpenSim.CAPS
|
||||
return responseString;
|
||||
}
|
||||
|
||||
private string PostNewAccount(string requestBody)
|
||||
private string PostNewAccount(string requestBody, string path)
|
||||
{
|
||||
string responseString;
|
||||
string firstName = "";
|
||||
@@ -110,7 +110,7 @@ namespace OpenSim.CAPS
|
||||
return responseString;
|
||||
}
|
||||
|
||||
private string GetConnectedClientsPage( string request )
|
||||
private string GetConnectedClientsPage(string request, string path)
|
||||
{
|
||||
string responseString;
|
||||
responseString = " <p> Listing connected Clients </p>";
|
||||
@@ -128,7 +128,7 @@ namespace OpenSim.CAPS
|
||||
return responseString;
|
||||
}
|
||||
|
||||
private string GetAccountsPage( string request )
|
||||
private string GetAccountsPage(string request, string path)
|
||||
{
|
||||
string responseString;
|
||||
responseString = "<p> Account management </p>";
|
||||
@@ -138,7 +138,7 @@ namespace OpenSim.CAPS
|
||||
return responseString;
|
||||
}
|
||||
|
||||
private string GetAdminPage( string request )
|
||||
private string GetAdminPage(string request, string path)
|
||||
{
|
||||
return AdminPage;
|
||||
}
|
||||
|
||||
@@ -76,11 +76,23 @@ namespace OpenSim.Servers
|
||||
string response;
|
||||
RestMethod handler;
|
||||
|
||||
string methodKey = String.Format("{0}: {1}", method, path);
|
||||
|
||||
if (m_restHandlers.TryGetValue(methodKey, out handler))
|
||||
string requestKey = String.Format("{0}: {1}", method, path);
|
||||
|
||||
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
|
||||
|
||||
@@ -4,5 +4,5 @@ using System.Text;
|
||||
|
||||
namespace OpenSim.CAPS
|
||||
{
|
||||
public delegate string RestMethod( string request );
|
||||
public delegate string RestMethod( string request, string path );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user