public ContextShowMiddleware(AllContextShowOptions options)
        {
            _response_contents = new ConcurrentDictionary <HttpResponse, string>();
            _request_option    = options.Request;
            _response_option   = options.Response;
            _main_option       = options.Main;

            //初始化Tab距离
            #region InitRequest
            RequestKeyTabs       = _request_option.KeyTabString;
            RequestValueTabs     = _request_option.ValueTabString;
            LessRequestValueTabs = _request_option.LessTabString;
            RequestHeaderTabs    = _request_option.HeaderTabString;
            #endregion

            #region InitResponse
            ResponseKeyTabs       = _response_option.KeyTabString;
            ResponseValueTabs     = _response_option.ValueTabString;
            LessResponseValueTabs = _response_option.LessTabString;
            ResponseHeaderTabs    = _response_option.HeaderTabString;
            #endregion



            //初始化匹配筛选器
            if (_main_option.IsFilterApiPaths)
            {
                EnterFilters = _main_option.EnterApis;
            }
            //初始化忽略筛选器
            IgnoreFilters = _main_option.IgnoreApis;

            RequestHeader  = $"{_main_option.SpliteLine}{RequestHeaderTabs}┌────────────────────────┐\r\n{RequestHeaderTabs}│                     Request                    │\r\n{RequestHeaderTabs}└────────────────────────┘\r\n";
            ResponseHeader = $"{ResponseHeaderTabs}┌────────────────────────┐\r\n{ResponseHeaderTabs}│                     Response                   │\r\n{ResponseHeaderTabs}└────────────────────────┘\r\n";
        }
Example #2
0
        public static IServiceCollection AddResponseShow(this IServiceCollection services, Action <ContextShowResponseOption> optionsAction = null)
        {
            if (Options == null)
            {
                Options = new AllContextShowOptions();
            }
            ContextShowResponseOption response = new ContextShowResponseOption();

            optionsAction?.Invoke(response);
            Options.Response = response;
            return(services);
        }