Ignore:
Timestamp:
May 17, 2023, 11:05:59 PM (18 months ago)
Author:
alloc
Message:

Added permission management APIs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/WebServer/src/WebUtils.cs

    r425 r434  
    44using System.Net;
    55using System.Text;
     6using UnityEngine.Profiling;
    67using Utf8Json;
    78using Webserver.WebAPI;
     
    1112namespace Webserver {
    1213        public static class WebUtils {
     14                static WebUtils () {
     15                        JsonWriter writer = new JsonWriter ();
     16                        writer.WriteBeginArray ();
     17                        writer.WriteEndArray ();
     18                        JsonEmptyData = writer.ToUtf8ByteArray ();
     19                }
     20
    1321                // ReSharper disable once MemberCanBePrivate.Global
    1422                public const string MimePlain = "text/plain";
     
    1725                public const string MimeJson = "application/json";
    1826               
    19                 private static readonly UnityEngine.Profiling.CustomSampler envelopeBuildSampler = UnityEngine.Profiling.CustomSampler.Create ("JSON_EnvelopeBuilding");
    20                 private static readonly UnityEngine.Profiling.CustomSampler netWriteSampler = UnityEngine.Profiling.CustomSampler.Create ("JSON_Write");
     27                private static readonly CustomSampler envelopeBuildSampler = CustomSampler.Create ("JSON_EnvelopeBuilding");
     28                private static readonly CustomSampler netWriteSampler = CustomSampler.Create ("JSON_Write");
    2129
    2230                public static void WriteText (HttpListenerResponse _resp, string _text, HttpStatusCode _statusCode = HttpStatusCode.OK, string _mimeType = null) {
     
    5664                }
    5765               
    58                
     66                public static readonly byte[] JsonEmptyData;
     67
    5968                private static readonly byte[] jsonRawDataKey = JsonWriter.GetEncodedPropertyNameWithBeginObject ("data"); // {"data":
    6069
     
    117126                }
    118127
     128                public static void SendEmptyResponse (RequestContext _context, HttpStatusCode _statusCode = HttpStatusCode.OK, byte[] _jsonInputData = null, string _errorCode = null, Exception _exception = null) {
     129                        PrepareEnvelopedResult (out JsonWriter writer);
     130                        writer.WriteRaw (JsonEmptyData);
     131                        SendEnvelopedResult (_context, ref writer, _statusCode, _jsonInputData, _errorCode, _exception);
     132                }
     133
     134
    119135                public static bool TryGetValue (this NameValueCollection _nameValueCollection, string _name, out string _result) {
    120136                        _result = _nameValueCollection [_name];
Note: See TracChangeset for help on using the changeset viewer.