public async Task <ReRouteDto> UpdateAsync(ReRouteDto routeDto) { await CheckPolicyAsync(); var reRoute = await _reRouteRepository.GetByReRouteIdAsync(routeDto.ReRouteId); reRoute.DangerousAcceptAnyServerCertificateValidator = routeDto.DangerousAcceptAnyServerCertificateValidator; reRoute.DownstreamScheme = routeDto.DownstreamScheme; reRoute.Key = routeDto.Key; reRoute.Priority = routeDto.Priority; reRoute.RequestIdKey = routeDto.RequestIdKey; reRoute.ReRouteIsCaseSensitive = routeDto.ReRouteIsCaseSensitive; reRoute.ServiceName = routeDto.ServiceName; reRoute.Timeout = routeDto.Timeout; reRoute.UpstreamHost = routeDto.UpstreamHost; reRoute.ModifyRouteInfo(routeDto.ReRouteName, routeDto.DownstreamPathTemplate, routeDto.UpstreamPathTemplate, routeDto.UpstreamHttpMethod, routeDto.DownstreamHostAndPorts); ApplyReRouteOptions(reRoute, routeDto); reRoute = await _reRouteRepository.UpdateAsync(reRoute, true); var reRouteDto = ObjectMapper.Map <ReRoute, ReRouteDto>(reRoute); await _distributedEventBus.PublishAsync(new OcelotConfigChangeCommand("ReRoute", "Modify")); return(reRouteDto); }
protected virtual void ApplyReRouteOptions(ReRoute reRoute, ReRouteDto routeDto) { reRoute.SetDownstreamHeader(routeDto.DownstreamHeaderTransform); reRoute.SetQueriesParamter(routeDto.AddQueriesToRequest); reRoute.SetRequestClaims(routeDto.AddClaimsToRequest); reRoute.SetRequestHeader(routeDto.AddHeadersToRequest); reRoute.SetRouteClaims(routeDto.RouteClaimsRequirement); reRoute.SetUpstreamHeader(routeDto.UpstreamHeaderTransform); reRoute.AuthenticationOptions.ApplyAuthOptions(routeDto.AuthenticationOptions.AuthenticationProviderKey, routeDto.AuthenticationOptions.AllowedScopes); reRoute.CacheOptions.ApplyCacheOption(routeDto.FileCacheOptions.TtlSeconds, routeDto.FileCacheOptions.Region); reRoute.HttpHandlerOptions.ApplyAllowAutoRedirect(routeDto.HttpHandlerOptions.AllowAutoRedirect); reRoute.HttpHandlerOptions.ApplyCookieContainer(routeDto.HttpHandlerOptions.UseCookieContainer); reRoute.HttpHandlerOptions.ApplyHttpProxy(routeDto.HttpHandlerOptions.UseProxy); reRoute.HttpHandlerOptions.ApplyHttpTracing(routeDto.HttpHandlerOptions.UseTracing); reRoute.LoadBalancerOptions.ApplyLoadBalancerOptions(routeDto.LoadBalancerOptions.Type, routeDto.LoadBalancerOptions.Key, routeDto.LoadBalancerOptions.Expiry); reRoute.QoSOptions.ApplyQosOptions(routeDto.QoSOptions.ExceptionsAllowedBeforeBreaking, routeDto.QoSOptions.DurationOfBreak, routeDto.QoSOptions.TimeoutValue); reRoute.RateLimitOptions.ApplyRateLimit(routeDto.RateLimitOptions.EnableRateLimiting); reRoute.RateLimitOptions.SetPeriodTimespan(routeDto.RateLimitOptions.Period, routeDto.RateLimitOptions.PeriodTimespan, routeDto.RateLimitOptions.Limit); reRoute.RateLimitOptions.SetClientWhileList(routeDto.RateLimitOptions.ClientWhitelist); reRoute.SecurityOptions.SetAllowIpList(routeDto.SecurityOptions.IPAllowedList); reRoute.SecurityOptions.SetBlockIpList(routeDto.SecurityOptions.IPBlockedList); }
public async Task <IActionResult> ReRoute(ReRouteDto routeDto) { ReRouteDto reRouteDto; if (routeDto.ReRouteId == 0) { reRouteDto = await _reRouteAppService.CreateAsync(routeDto); } else { reRouteDto = await _reRouteAppService.UpdateAsync(routeDto); } return(RedirectToAction("ReRoute", "OcelotConfiguration", new { routeId = reRouteDto.ReRouteId })); }
public async Task <ReRouteDto> CreateAsync(ReRouteDto routeDto) { await CheckPolicyAsync(); var reRoute = ObjectMapper.Map <ReRouteDto, ReRoute>(routeDto); ApplyReRouteOptions(reRoute, routeDto); reRoute = await _reRouteRepository.InsertAsync(reRoute, true); var reRouteDto = ObjectMapper.Map <ReRoute, ReRouteDto>(reRoute); await _distributedEventBus.PublishAsync(new OcelotConfigChangeCommand("ReRoute", "Create")); return(reRouteDto); }
public async Task <ReRouteDto> CreateAsync(ReRouteDto routeDto) { await CheckPolicyAsync(); var reRoute = ObjectMapper.Map <ReRouteDto, ReRoute>(routeDto); ApplyReRouteOptions(reRoute, routeDto); reRoute = await _reRouteRepository.InsertAsync(reRoute, true); var reRouteDto = ObjectMapper.Map <ReRoute, ReRouteDto>(reRoute); await _eventPublisher.PublishAsync(ApiGatewayDomainConsts.Events_OcelotConfigChanged, Clock.Now); return(reRouteDto); }