- Timestamp:
- Sep 4, 2018, 2:33:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/Handlers/ApiHandler.cs
r325 r326 7 7 namespace AllocsFixes.NetConnections.Servers.Web.Handlers { 8 8 public class ApiHandler : PathHandler { 9 private readonly Dictionary<string, WebAPI> apis = new Dictionary<string,WebAPI> ();9 private readonly Dictionary<string, WebAPI> apis = new CaseInsensitiveStringDictionary<WebAPI> (); 10 10 private readonly string staticPart; 11 11 … … 18 18 if (ctor != null) { 19 19 WebAPI apiInstance = (WebAPI) ctor.Invoke (new object [0]); 20 addApi ( t.Name.ToLower (), apiInstance);20 addApi (apiInstance.Name, apiInstance); 21 21 } 22 22 } … … 52 52 } 53 53 54 foreach (KeyValuePair<string, WebAPI> kvp in apis) { 55 if (apiName.StartsWith (kvp.Key)) { 56 try { 57 kvp.Value.HandleRequest (req, resp, user, permissionLevel); 58 return; 59 } catch (Exception e) { 60 Log.Error ("Error in ApiHandler.HandleRequest(): Handler {0} threw an exception:", kvp.Key); 61 Log.Exception (e); 62 resp.StatusCode = (int) HttpStatusCode.InternalServerError; 63 return; 64 } 54 WebAPI api; 55 if (apis.TryGetValue (apiName, out api)) { 56 try { 57 api.HandleRequest (req, resp, user, permissionLevel); 58 return; 59 } catch (Exception e) { 60 Log.Error ("Error in ApiHandler.HandleRequest(): Handler {0} threw an exception:", api.Name); 61 Log.Exception (e); 62 resp.StatusCode = (int) HttpStatusCode.InternalServerError; 63 return; 65 64 } 66 65 } 67 66 68 67 Log.Out ("Error in ApiHandler.HandleRequest(): No handler found for API \"" + apiName + "\""); 69 68 resp.StatusCode = (int) HttpStatusCode.NotFound;
Note:
See TracChangeset
for help on using the changeset viewer.