Ignore:
Timestamp:
Aug 1, 2022, 12:54:31 PM (2 years ago)
Author:
alloc
Message:

Switched to use SpaceWizards.HttpListener

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/MapRendering/Web/Handlers/ApiHandler.cs

    r367 r382  
    44using System.Reflection;
    55using AllocsFixes.NetConnections.Servers.Web.API;
     6using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
     7using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
    68
    79namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
    8         public class ApiHandler : PathHandler {
     10        public class ApiHandler : AbsHandler {
    911                private readonly Dictionary<string, WebAPI> apis = new CaseInsensitiveStringDictionary<WebAPI> ();
    1012
     
    3537#endif
    3638
    37                 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
     39                public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con,
    3840                        int _permissionLevel) {
    39                         string apiName = _req.Url.AbsolutePath.Remove (0, urlBasePath.Length);
     41                        string apiName = _requestPath.Remove (0, urlBasePath.Length);
    4042
    4143                        if (!apis.TryGetValue (apiName, out WebAPI api)) {
     
    4749                        if (!AuthorizeForApi (apiName, _permissionLevel)) {
    4850                                _resp.StatusCode = (int) HttpStatusCode.Forbidden;
    49                                 if (_user != null) {
     51                                if (_con != null) {
    5052                                        //Log.Out ($"{nameof(ApiHandler)}: user '{user.SteamID}' not allowed to execute '{apiName}'");
    5153                                }
     
    5860                                apiHandlerSampler.Begin ();
    5961#endif
    60                                 api.HandleRequest (_req, _resp, _user, _permissionLevel);
     62                                api.HandleRequest (_req, _resp, _con, _permissionLevel);
    6163#if ENABLE_PROFILER
    6264                                apiHandlerSampler.End ();
Note: See TracChangeset for help on using the changeset viewer.