Beispiel #1
0
        public EndpointDescriptor GetEndpointDescriptor <T>(
            Expression <Action <T> > endpointCapture,
            ClaimsPrincipal claimsPrincipal
            ) where T : class
        {
            var methodCall = this._callCollector.CollectMethodCall(endpointCapture);

            if (methodCall == null)
            {
                return(null);
            }

            var actionDescriptor = this._actionDescriptorResolver.Resolve(methodCall.Target, methodCall.Method);

            if (actionDescriptor == null)
            {
                throw new InvalidOperationException("Expression does not call application action");
            }

            var endpointDescriptor = new EndpointDescriptor(actionDescriptor, methodCall.Arguments, "localhost:54287", "http");

            if (!this._accessValidator.CanAccess(claimsPrincipal, endpointDescriptor.Policies))
            {
                return(null);
            }

            return(endpointDescriptor);
        }
Beispiel #2
0
        public string MakeHref(EndpointDescriptor endpointDescriptor)
        {
            ExtractParameters(
                endpointDescriptor.ArgumentsCollection,
                out var queryParameters,
                out var routeParameters
                );

            var template = endpointDescriptor.Template;

            var href = $"{endpointDescriptor.Protocol}://{endpointDescriptor.Host}/{template}";

            href = href.InterpolateRouteParameters(routeParameters);
            href = href.InterpolateQueryParameters(queryParameters);

            return(href);
        }