diff options
Diffstat (limited to 'OpenSim.Servers/BaseHttpServer.cs')
-rw-r--r-- | OpenSim.Servers/BaseHttpServer.cs | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/OpenSim.Servers/BaseHttpServer.cs b/OpenSim.Servers/BaseHttpServer.cs index 2f73f46..0a123b7 100644 --- a/OpenSim.Servers/BaseHttpServer.cs +++ b/OpenSim.Servers/BaseHttpServer.cs | |||
@@ -12,9 +12,30 @@ namespace OpenSim.Servers | |||
12 | { | 12 | { |
13 | public class BaseHttpServer | 13 | public class BaseHttpServer |
14 | { | 14 | { |
15 | protected class RestMethodEntry | ||
16 | { | ||
17 | private string m_path; | ||
18 | public string Path | ||
19 | { | ||
20 | get { return m_path; } | ||
21 | } | ||
22 | |||
23 | private RestMethod m_restMethod; | ||
24 | public RestMethod RestMethod | ||
25 | { | ||
26 | get { return m_restMethod; } | ||
27 | } | ||
28 | |||
29 | public RestMethodEntry( string path, RestMethod restMethod ) | ||
30 | { | ||
31 | m_path = path; | ||
32 | m_restMethod = restMethod; | ||
33 | } | ||
34 | } | ||
35 | |||
15 | protected Thread m_workerThread; | 36 | protected Thread m_workerThread; |
16 | protected HttpListener m_httpListener; | 37 | protected HttpListener m_httpListener; |
17 | protected Dictionary<string, RestMethod> m_restHandlers = new Dictionary<string, RestMethod>(); | 38 | protected Dictionary<string, RestMethodEntry> m_restHandlers = new Dictionary<string, RestMethodEntry>(); |
18 | protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); | 39 | protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); |
19 | protected int m_port; | 40 | protected int m_port; |
20 | 41 | ||
@@ -29,7 +50,7 @@ namespace OpenSim.Servers | |||
29 | 50 | ||
30 | if (!this.m_restHandlers.ContainsKey(methodKey)) | 51 | if (!this.m_restHandlers.ContainsKey(methodKey)) |
31 | { | 52 | { |
32 | this.m_restHandlers.Add(methodKey, handler); | 53 | this.m_restHandlers.Add(methodKey, new RestMethodEntry( path, handler )); |
33 | return true; | 54 | return true; |
34 | } | 55 | } |
35 | 56 | ||
@@ -74,7 +95,6 @@ namespace OpenSim.Servers | |||
74 | protected virtual string ParseREST(string request, string path, string method) | 95 | protected virtual string ParseREST(string request, string path, string method) |
75 | { | 96 | { |
76 | string response; | 97 | string response; |
77 | RestMethod handler; | ||
78 | 98 | ||
79 | string requestKey = String.Format("{0}: {1}", method, path); | 99 | string requestKey = String.Format("{0}: {1}", method, path); |
80 | 100 | ||
@@ -89,10 +109,14 @@ namespace OpenSim.Servers | |||
89 | } | 109 | } |
90 | } | 110 | } |
91 | } | 111 | } |
92 | 112 | ||
93 | if (m_restHandlers.TryGetValue(bestMatch, out handler)) | 113 | RestMethodEntry restMethodEntry; |
114 | if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry)) | ||
94 | { | 115 | { |
95 | response = handler(request, path); | 116 | RestMethod restMethod = restMethodEntry.RestMethod; |
117 | |||
118 | string param = path.Substring( restMethodEntry.Path.Length ); | ||
119 | response = restMethod(request, path, param); | ||
96 | 120 | ||
97 | } | 121 | } |
98 | else | 122 | else |