Ejemplo n.º 1
0
        internal MapRouteBuilder Register(string urlTemplate, string method, HandlerFunc handler)
        {
            if (string.IsNullOrWhiteSpace(method))
            {
                throw new ArgumentNullException("method");
            }
            if (string.IsNullOrWhiteSpace(urlTemplate))
            {
                throw new ArgumentNullException("urlTemplate");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            var segments = RouteBuilderHelper.GetUrlTemplateSegments(urlTemplate);
            var route    = new Route
            {
                Method   = method,
                Segments = segments,
                Handler  = handler
            };

            _routes.Add(route);

            return(this);
        }
Ejemplo n.º 2
0
        internal RouteBuilder(IAppBuilder app, string urlTemplate)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }
            if (string.IsNullOrWhiteSpace(urlTemplate))
            {
                throw new ArgumentNullException("urlTemplate");
            }

            App = app;
            _urlTemplateSegments = RouteBuilderHelper.GetUrlTemplateSegments(urlTemplate);
        }