Changeset 326 for binary-improvements/MapRendering/Web/Handlers
- Timestamp:
- Sep 4, 2018, 2:33:52 PM (6 years ago)
- Location:
- binary-improvements/MapRendering/Web/Handlers
- Files:
-
- 2 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; -
binary-improvements/MapRendering/Web/Handlers/ItemIconHandler.cs
r325 r326 37 37 requestFileName = requestFileName.Remove (requestFileName.LastIndexOf ('.')); 38 38 39 if (icons.ContainsKey (requestFileName) && req.Url.AbsolutePath. ToLower ().EndsWith (".png")) {39 if (icons.ContainsKey (requestFileName) && req.Url.AbsolutePath.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) { 40 40 resp.ContentType = MimeType.GetMimeType (".png"); 41 41 … … 128 128 foreach (string file in Directory.GetFiles (modIconsPath)) { 129 129 try { 130 if (file. ToLower ().EndsWith (".png")) {130 if (file.EndsWith (".png", StringComparison.OrdinalIgnoreCase)) { 131 131 string name = Path.GetFileNameWithoutExtension (file); 132 132 Texture2D tex = new Texture2D (1, 1, TextureFormat.ARGB32, false);
Note:
See TracChangeset
for help on using the changeset viewer.