From 08d5d10d62df2c1c418e7a39cadb6662ea66b228 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 11 Apr 2007 14:14:19 +0000 Subject: * Started on converting UserHTTPServer to BaseHttpServer * Added a 'param' param to the RestMethod * Added RestHandlerEntry to store more info about the 'rest' handler --- OpenSim.Servers/BaseHttpServer.cs | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'OpenSim.Servers/BaseHttpServer.cs') 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 { public class BaseHttpServer { + protected class RestMethodEntry + { + private string m_path; + public string Path + { + get { return m_path; } + } + + private RestMethod m_restMethod; + public RestMethod RestMethod + { + get { return m_restMethod; } + } + + public RestMethodEntry( string path, RestMethod restMethod ) + { + m_path = path; + m_restMethod = restMethod; + } + } + protected Thread m_workerThread; protected HttpListener m_httpListener; - protected Dictionary m_restHandlers = new Dictionary(); + protected Dictionary m_restHandlers = new Dictionary(); protected Dictionary m_rpcHandlers = new Dictionary(); protected int m_port; @@ -29,7 +50,7 @@ namespace OpenSim.Servers if (!this.m_restHandlers.ContainsKey(methodKey)) { - this.m_restHandlers.Add(methodKey, handler); + this.m_restHandlers.Add(methodKey, new RestMethodEntry( path, handler )); return true; } @@ -74,7 +95,6 @@ namespace OpenSim.Servers protected virtual string ParseREST(string request, string path, string method) { string response; - RestMethod handler; string requestKey = String.Format("{0}: {1}", method, path); @@ -89,10 +109,14 @@ namespace OpenSim.Servers } } } - - if (m_restHandlers.TryGetValue(bestMatch, out handler)) + + RestMethodEntry restMethodEntry; + if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry)) { - response = handler(request, path); + RestMethod restMethod = restMethodEntry.RestMethod; + + string param = path.Substring( restMethodEntry.Path.Length ); + response = restMethod(request, path, param); } else -- cgit v1.1