aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorlbsa712007-03-29 19:22:01 +0000
committerlbsa712007-03-29 19:22:01 +0000
commit30c5be370489f9620e0f199526c80f5c34f16faa (patch)
treec56a7ec877a9f5f935b25c3c4703b6d8bfcde662
parent* RestMethod now uses same pattern as XmlRpcMethod (diff)
downloadopensim-SC_OLD-30c5be370489f9620e0f199526c80f5c34f16faa.zip
opensim-SC_OLD-30c5be370489f9620e0f199526c80f5c34f16faa.tar.gz
opensim-SC_OLD-30c5be370489f9620e0f199526c80f5c34f16faa.tar.bz2
opensim-SC_OLD-30c5be370489f9620e0f199526c80f5c34f16faa.tar.xz
* 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.
-rw-r--r--OpenSim.RegionServer/CAPS/AdminWebFront.cs14
-rw-r--r--Servers/BaseHttpServer.cs20
-rw-r--r--Servers/IRestHandler.cs2
3 files changed, 24 insertions, 12 deletions
diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs
index 3596ffa..6473878 100644
--- a/OpenSim.RegionServer/CAPS/AdminWebFront.cs
+++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs
@@ -35,8 +35,8 @@ namespace OpenSim.CAPS
35 server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount ); 35 server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
36 server.AddRestHandler("POST", "/Admin/Login", PostLogin ); 36 server.AddRestHandler("POST", "/Admin/Login", PostLogin );
37 } 37 }
38 38
39 private string GetWelcomePage( string request ) 39 private string GetWelcomePage(string request, string path)
40 { 40 {
41 string responseString; 41 string responseString;
42 responseString = "Welcome to the OpenSim Admin Page"; 42 responseString = "Welcome to the OpenSim Admin Page";
@@ -44,7 +44,7 @@ namespace OpenSim.CAPS
44 return responseString; 44 return responseString;
45 } 45 }
46 46
47 private string PostLogin(string requestBody) 47 private string PostLogin(string requestBody, string path)
48 { 48 {
49 string responseString; 49 string responseString;
50// Console.WriteLine(requestBody); 50// Console.WriteLine(requestBody);
@@ -61,7 +61,7 @@ namespace OpenSim.CAPS
61 return responseString; 61 return responseString;
62 } 62 }
63 63
64 private string PostNewAccount(string requestBody) 64 private string PostNewAccount(string requestBody, string path)
65 { 65 {
66 string responseString; 66 string responseString;
67 string firstName = ""; 67 string firstName = "";
@@ -110,7 +110,7 @@ namespace OpenSim.CAPS
110 return responseString; 110 return responseString;
111 } 111 }
112 112
113 private string GetConnectedClientsPage( string request ) 113 private string GetConnectedClientsPage(string request, string path)
114 { 114 {
115 string responseString; 115 string responseString;
116 responseString = " <p> Listing connected Clients </p>"; 116 responseString = " <p> Listing connected Clients </p>";
@@ -128,7 +128,7 @@ namespace OpenSim.CAPS
128 return responseString; 128 return responseString;
129 } 129 }
130 130
131 private string GetAccountsPage( string request ) 131 private string GetAccountsPage(string request, string path)
132 { 132 {
133 string responseString; 133 string responseString;
134 responseString = "<p> Account management </p>"; 134 responseString = "<p> Account management </p>";
@@ -138,7 +138,7 @@ namespace OpenSim.CAPS
138 return responseString; 138 return responseString;
139 } 139 }
140 140
141 private string GetAdminPage( string request ) 141 private string GetAdminPage(string request, string path)
142 { 142 {
143 return AdminPage; 143 return AdminPage;
144 } 144 }
diff --git a/Servers/BaseHttpServer.cs b/Servers/BaseHttpServer.cs
index 7c2a195..174402a 100644
--- a/Servers/BaseHttpServer.cs
+++ b/Servers/BaseHttpServer.cs
@@ -76,11 +76,23 @@ namespace OpenSim.Servers
76 string response; 76 string response;
77 RestMethod handler; 77 RestMethod handler;
78 78
79 string methodKey = String.Format("{0}: {1}", method, path); 79 string requestKey = String.Format("{0}: {1}", method, path);
80 80
81 if (m_restHandlers.TryGetValue(methodKey, out handler)) 81 string bestMatch = String.Empty;
82 foreach( string currentKey in m_restHandlers.Keys )
83 {
84 if( requestKey.StartsWith( currentKey ))
85 {
86 if(currentKey.Length > bestMatch.Length )
87 {
88 bestMatch = currentKey;
89 }
90 }
91 }
92
93 if (m_restHandlers.TryGetValue(bestMatch, out handler))
82 { 94 {
83 response = handler(request); 95 response = handler(request, path);
84 96
85 } 97 }
86 else 98 else
diff --git a/Servers/IRestHandler.cs b/Servers/IRestHandler.cs
index deb77d8..46459ff 100644
--- a/Servers/IRestHandler.cs
+++ b/Servers/IRestHandler.cs
@@ -4,5 +4,5 @@ using System.Text;
4 4
5namespace OpenSim.CAPS 5namespace OpenSim.CAPS
6{ 6{
7 public delegate string RestMethod( string request ); 7 public delegate string RestMethod( string request, string path );
8} 8}