Пример #1
0
        void PathVariable()
        {
            string patthen = "g/{id}/{extract}/{var}";
            string test    = "g/0/2343324/dcsdasccd-c-dsas-s";

            foreach (var item in PathURLExtractor.ExtractPathVariable(patthen, test))
            {
                Console.WriteLine("{0}:{1}", item.Key, item.Value);
            }
        }
Пример #2
0
        private void InvokeServlet(HttpServlet resource, string remainingURL, HttpRequest request, HttpResponse response)
        {
            response.SetHeader(HeaderFields.CacheControl, HeaderFields.CacheControl_NoCahe);

            ServletPathPatternAttribute pattern =
                resource.GetType().GetCustomAttribute(typeof(ServletPathPatternAttribute))
                as ServletPathPatternAttribute;

            if (pattern != null)
            {
                foreach (var item in PathURLExtractor.ExtractPathVariable(pattern.PathPattern, remainingURL))
                {
                    request.AddParameter(item.Key, item.Value);
                }
            }

            resource?.Dispatch(request, response);
        }