Inheritance: IPomonaRequestProcessor
コード例 #1
0
        public IEnumerable <RouteAction> Resolve(Route route, HttpMethod method)
        {
            var resourceItemType = route.ResultItemType as ResourceType;

            if (resourceItemType == null)
            {
                yield break;
            }

            RouteAction func = null;

            switch (method)
            {
            case HttpMethod.Get:
                func = ResolveGet(route, resourceItemType);
                break;
            }
            if (func != null)
            {
                yield return(func);
            }
        }
コード例 #2
0
        public virtual IEnumerable <RouteAction> Resolve(Route route, HttpMethod method)
        {
            var rootRoute = route as DataSourceRootRoute;

            if (rootRoute != null)
            {
                yield return(ResolveGetRootResource(rootRoute));
            }

            var resourceItemType = route.ResultItemType as ResourceType;

            if (resourceItemType == null)
            {
                yield break;
            }

            RouteAction func = null;

            switch (method)
            {
            case HttpMethod.Get:
                func = ResolveGet(route, resourceItemType);
                break;

            case HttpMethod.Post:
                func = ResolvePost(route, resourceItemType);
                break;

            case HttpMethod.Patch:
                func = ResolvePatch(route, resourceItemType);
                break;
            }
            if (func != null)
            {
                yield return(func);
            }
        }
コード例 #3
0
        private IEnumerable <RouteAction> ResolveNonCached(Route route, HttpMethod method)
        {
            // First check whether there's a matching handler for type
            if (!route.AllowedMethods.HasFlag(method))
            {
                return
                    (RouteAction.Create(pr => ThrowMethodNotAllowedForType(method, route.AllowedMethods)).WrapAsArray());
            }

            var routeActions = this.nestedActionResolvers
                               .SelectMany(x => x.Resolve(route, method).EmptyIfNull()).ToList();

            if (routeActions.Count > 0)
            {
                return(routeActions);
            }

            return(RouteAction.Create(x =>
            {
                throw new PomonaServerException("Unable to resolve action for route.",
                                                null,
                                                statusCode: HttpStatusCode.Forbidden);
            }).WrapAsArray());
        }