public static ICorsPolicySource ThatApplies( this IEnumerable <ICorsPolicySource> sources, CorsConfiguration corsConfiguration, ActionDescriptor actionDescriptor, Configuration configuration, HttpConfiguration httpConfiguration) { return(corsConfiguration.PolicySources.ThatApply(sources, new ActionConfigurationContext(configuration, httpConfiguration, actionDescriptor.Action, actionDescriptor.Route)) .FirstOrDefault()); }
public CorsBehavior(IBehaviorChain behaviorChain, ICorsEngine corsEngine, CorsConfiguration corsConfiguration, ActionDescriptor actionDescriptor, HttpRequestMessage requestMessage, IEnumerable <ICorsPolicySource> policySources, Configuration configuration, HttpConfiguration httpConfiguration) : base(behaviorChain) { _configuration = configuration; _httpConfiguration = httpConfiguration; _corsEngine = corsEngine; _corsConfiguration = corsConfiguration; _actionDescriptor = actionDescriptor; _requestMessage = requestMessage; _policySources = policySources; }
public static ConfigurationDsl EnableCors( this ConfigurationDsl configuration, Action <CorsConfigurationDsl> configure = null) { var corsConfiguration = new CorsConfiguration(); configure?.Invoke(new CorsConfigurationDsl(corsConfiguration)); return(configuration .ConfigureHttpRouteDecorators(x => x .Append <OptionsRouteDecorator>(a => corsConfiguration.PolicySources.ThatApplyTo(a).Any())) .ConfigureBehaviors(x => x .Prepend <CorsBehavior>(a => corsConfiguration.PolicySources.ThatApplyTo(a).Any())) .ConfigureRegistry(x => x .Register(corsConfiguration) .RegisterPlugin(corsConfiguration.CorsEngine) .RegisterPlugins(corsConfiguration.PolicySources))); }
public CorsConfigurationDsl(CorsConfiguration configuration) { _configuration = configuration; }