Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Spring cloud gateway routing #3031

Merged
merged 32 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4783d45
draft
pj892031 Aug 10, 2023
e44f966
fixes
pj892031 Aug 11, 2023
d0376df
HeaderRouteStepFilterFactoryTest
pj892031 Aug 11, 2023
b206dfd
ByBasePathTest
pj892031 Aug 11, 2023
f5ef78f
ByHeaderTest
pj892031 Aug 11, 2023
8a82aaa
RouteDefinitionProducerTest
pj892031 Aug 11, 2023
df346d1
X509Test
pj892031 Aug 11, 2023
561c9e0
HttpBasicPassticketTest
pj892031 Aug 11, 2023
8262f49
RouteLocatorTest
pj892031 Aug 14, 2023
77691e8
remove test of refactored code
pj892031 Aug 14, 2023
8fb762f
Merge branch 'v2.x.x' into reboot/scgwRouting
pj892031 Aug 14, 2023
1f7ecd5
fix licenses and checkstyle errors
arxioly Aug 14, 2023
92988de
fix few more checkstyle errors
arxioly Aug 14, 2023
24de00e
hotfix routing of gateway services - custom routing rules
pj892031 Aug 15, 2023
fb8d765
fix support empty gatewayUrl in routing
pj892031 Aug 15, 2023
4570ca9
Merge branch 'v2.x.x' into reboot/scgwRouting
pj892031 Aug 15, 2023
97bc806
fixes
pj892031 Aug 15, 2023
c24ba58
fixes
pj892031 Aug 16, 2023
55d33b3
fix CORS unit test
pj892031 Aug 16, 2023
5c035c3
fix cloud spring gateway tests
pj892031 Aug 16, 2023
d416d4b
fix API gateway tests by removing fix in testing class - some tests d…
pj892031 Aug 16, 2023
2da5586
fix CorsPerServiceTest
pj892031 Aug 16, 2023
eee41b1
fix tests
pj892031 Aug 16, 2023
ff63e28
fix Sonar issues
pj892031 Aug 17, 2023
212c613
JavaDoc update
pj892031 Aug 17, 2023
1274239
Merge branch 'v2.x.x' into reboot/scgwRouting
pj892031 Aug 17, 2023
cff6248
rename header
pj892031 Aug 17, 2023
c2c5d16
fix constant
pj892031 Aug 17, 2023
0511b4b
remove unused import
pj892031 Aug 17, 2023
19de210
Merge branch 'v2.x.x' into reboot/scgwRouting
pj892031 Aug 21, 2023
cb3e02e
code review
pj892031 Aug 22, 2023
ece190a
Merge branch 'v2.x.x' into reboot/scgwRouting
pj892031 Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ jobs:
image: ghcr.io/balhar-jakub/gateway-service:${{ github.run_id }}-${{ github.run_number }}
cloud-gateway-service:
image: ghcr.io/balhar-jakub/cloud-gateway-service:${{ github.run_id }}-${{ github.run_number }}
env:
APIML_SERVICE_GATEWAY_PROXY_ENABLED: false
discoverable-client:
image: ghcr.io/balhar-jakub/discoverable-client:${{ github.run_id }}-${{ github.run_number }}
mock-services:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@
package org.zowe.apiml.cloudgatewayservice.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
import org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties;
import org.springframework.cloud.gateway.filter.FilterDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zowe.apiml.cloudgatewayservice.service.ProxyRouteLocator;
import org.zowe.apiml.cloudgatewayservice.service.RouteLocator;
import org.zowe.apiml.util.CorsUtils;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -33,20 +26,6 @@ public class RoutingConfig {
@Value("${apiml.service.ignoredHeadersWhenCorsEnabled:-}")
private String ignoredHeadersWhenCorsEnabled;

@Bean
@ConditionalOnProperty(name = "apiml.service.gateway.proxy.enabled", havingValue = "false")
public RouteLocator apimlDiscoveryRouteDefLocator(
ReactiveDiscoveryClient discoveryClient, DiscoveryLocatorProperties properties, List<FilterDefinition> filters, ApplicationContext context, CorsUtils corsUtils) {
return new RouteLocator(discoveryClient, properties, filters, context, corsUtils);
}

@Bean
@ConditionalOnProperty(name = "apiml.service.gateway.proxy.enabled", havingValue = "true")
public RouteLocator proxyRouteDefLocator(
ReactiveDiscoveryClient discoveryClient, DiscoveryLocatorProperties properties, List<FilterDefinition> filters, ApplicationContext context, CorsUtils corsUtils) {
return new ProxyRouteLocator(discoveryClient, properties, filters, context, corsUtils);
}

@Bean
public List<FilterDefinition> filters() {
FilterDefinition circuitBreakerFilter = new FilterDefinition();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/

package org.zowe.apiml.cloudgatewayservice.filters;

import lombok.Data;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Service;

/**
* This filter is responsible to update request header during the routing. The header contain a locator to which server
* route. It could contain also multiple steps separated by /.
*
* In the case header contain multiple steps the filter remove just the first part, otherwise it remove header at all.
*
* Examples:
* "step1/step2/step3" > "step2/step3"
* "node" > null (removed)
*/
@Service
public class HeaderRouteStepFilterFactory extends AbstractGatewayFilterFactory<HeaderRouteStepFilterFactory.Config> {

public HeaderRouteStepFilterFactory() {
super(Config.class);
}

@Override
public GatewayFilter apply(Config config) {
String header = config.getHeader();
return (exchange, chain) -> {
if (exchange.getRequest().getHeaders().containsKey(header)) {
exchange.mutate().request(request -> exchange.getRequest().mutate().headers(headers -> {
String headerValue = headers.getFirst(header);
int index = headerValue.indexOf("/");
if ((index >= 0) && (index + 1 < headerValue.length())) {
headers.set(header, headerValue.substring(index + 1));
} else {
headers.remove(header);
}
}));
}

return chain.filter(exchange);
};
}

@Data
public static class Config {

private String header;

}

}

This file was deleted.

Loading
Loading