Пример #1
0
 /// <summary>
 /// Create the URL pattern from regex.
 /// </summary>
 /// <param name="regex">Regex to match.</param>
 /// <param name="method">Optional filter by HTTP method (see HttpMethods for options).</param>
 public URL(Regex regex, string method = null)
 {
     _pattern      = regex.ToString();
     _matchingType = UrlMatchingType.RegEx;
     _methodFilter = method;
     _regex        = regex;
 }
Пример #2
0
        /// <summary>
        /// Create the URL pattern.
        /// </summary>
        /// <param name="pattern">Pattern to match.</param>
        /// <param name="method">Optional filter by HTTP method (see HttpMethods for options).</param>
        /// <param name="matchType">How to match pattern.</param>
        public URL(string pattern, string method = null, UrlMatchingType matchType = UrlMatchingType.Exact)
        {
            // set pattern and matching type
            _pattern      = pattern;
            _matchingType = matchType;
            _methodFilter = method;

            // if its regex matching, create regex object
            if (_matchingType == UrlMatchingType.RegEx)
            {
                _regex = new Regex(_pattern);
            }
        }