public HttpResponse HttpRequestHandler(HttpRequest r)
        {
            if (r == null)
            {
                throw new Exception("20200111 incoming r is null!!!");
            }

            if (r.Path.Length > 1 && r.Path.EndsWith('/'))
            {
                r.Path = r.Path.Remove(r.Path.Length - 1);
            }

            RouteHandler handler = null;

            if (RouteHandlers == null || !RouteHandlers.TryGetValue(r.Path, out handler))
            {
                if (RegexRouteHandlers != null)
                {
                    foreach (var pattern in RegexRouteHandlers.Keys)
                    {
                        if (Regex.Match(r.Path, pattern).Success)
                        {
                            handler = RegexRouteHandlers[pattern];
                            break;
                        }
                    }
                }
            }

            if (handler == null)
            {
                return(AddHeader(HttpResponse.NotFound));
            }

            HttpResponse responseProducedByLogicHandler = null;

            try
            {
                responseProducedByLogicHandler = handler.OnRequest(r);
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogAsync(ex);
                return(AddHeader(HttpResponse.InternalServerError));
            }

            if (r.QueryString != null && r.QueryString.Count != 0)
            {
                AccessLogger.LogAsync(r.Method + " " + r.Path + "?" + QueryStringBuilder.CreateQueryStringFromMap(r.QueryString).ToString()
                                      + Environment.NewLine + responseProducedByLogicHandler.StatusCode);
            }
            else
            {
                AccessLogger.LogAsync(r.Method + " " + r.Path
                                      + Environment.NewLine + responseProducedByLogicHandler.StatusCode);
            }

            return(AddHeader(responseProducedByLogicHandler));
        }
 /// <summary>
 /// Logs access to encrypted data if a logger is available.
 /// </summary>
 /// <param name="recordId"></param>
 /// <param name="fieldName"></param>
 /// <param name="accessType"></param>
 private void LogAccess(Guid recordId, string fieldName, AccessType accessType)
 {
     AccessLogger?.LogAccess(
         new RecordPointer <Guid>(this.RecordType, recordId),
         new RecordPointer <Guid>("systemuser", ExecutionContext.InitiatingUserId),
         fieldName,
         accessType);
 }