diff options
author | lbsa71 | 2007-04-11 14:14:19 +0000 |
---|---|---|
committer | lbsa71 | 2007-04-11 14:14:19 +0000 |
commit | 08d5d10d62df2c1c418e7a39cadb6662ea66b228 (patch) | |
tree | 19ac712ff6cc51f0563bc99767fc4331061214a8 /OpenSim.Servers | |
parent | deleted OpenSim.Terrain.BasicTerrain.dll from the bin folder, don't think the... (diff) | |
download | opensim-SC-08d5d10d62df2c1c418e7a39cadb6662ea66b228.zip opensim-SC-08d5d10d62df2c1c418e7a39cadb6662ea66b228.tar.gz opensim-SC-08d5d10d62df2c1c418e7a39cadb6662ea66b228.tar.bz2 opensim-SC-08d5d10d62df2c1c418e7a39cadb6662ea66b228.tar.xz |
* Started on converting UserHTTPServer to BaseHttpServer
* Added a 'param' param to the RestMethod
* Added RestHandlerEntry to store more info about the 'rest' handler
Diffstat (limited to '')
-rw-r--r-- | OpenSim.Servers/BaseHttpServer.cs | 36 | ||||
-rw-r--r-- | OpenSim.Servers/IRestHandler.cs | 2 |
2 files changed, 31 insertions, 7 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 |
diff --git a/OpenSim.Servers/IRestHandler.cs b/OpenSim.Servers/IRestHandler.cs index 08737cc..c322505 100644 --- a/OpenSim.Servers/IRestHandler.cs +++ b/OpenSim.Servers/IRestHandler.cs | |||
@@ -4,5 +4,5 @@ using System.Text; | |||
4 | 4 | ||
5 | namespace OpenSim.Servers | 5 | namespace OpenSim.Servers |
6 | { | 6 | { |
7 | public delegate string RestMethod( string request, string path ); | 7 | public delegate string RestMethod( string request, string path, string param ); |
8 | } | 8 | } |