예제 #1
0
        private async Task <string> ApplyRule(string pageAddress)
        {
            // ToDo: implement handling of a case when the rule is NULL.
            var rule = _ruleRepository.GetRule(pageAddress);

            var pageContent = await _agent.GetContent($"http://{pageAddress}");

            return(ContentFilter.Apply(pageContent, rule));
        }
예제 #2
0
        public async Task <IActionResult> Test(string page, string rule = null)
        {
            if (string.IsNullOrWhiteSpace(page))
            {
                return(BadRequest($"The '{nameof(page)}' parameter is mandatory."));
            }

            if (string.IsNullOrWhiteSpace(rule))
            {
                rule = _ruleRepository.GetRule(page);

                if (rule == null)
                {
                    return(NotFound($"Rule for site '{page}' not found."));
                }
            }

            var pageContent = await _agent.GetContent($"http://{page}");

            var textResult = ContentFilter.Apply(pageContent, rule);

            return(new OkObjectResult(textResult));
        }