mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
✨ 添加新特性。 支持quartz 定时任务
This commit is contained in:
1 parent
7083019d6b
commit
f74e338e07
70 files changed
+2919
-22
No files matched your search
@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
@Primary
|
||||
@AllArgsConstructor
|
||||
public class SwaggerProvider implements SwaggerResourcesProvider {
|
||||
private static final String API_URI = "/v2/api-docs";
|
||||
public static final String API_URI = "/v2/api-docs";
|
||||
private final RouteDefinitionRepository routeDefinitionRepository;
|
||||
private final FilterIgnorePropertiesConfig filterIgnorePropertiesConfig;
|
||||
|
||||
@@ -50,14 +50,14 @@ public class SwaggerProvider implements SwaggerResourcesProvider {
|
||||
List<RouteDefinition> routes = new ArrayList<>();
|
||||
routeDefinitionRepository.getRouteDefinitions().subscribe(route -> routes.add(route));
|
||||
routes.forEach(routeDefinition -> routeDefinition.getPredicates().stream()
|
||||
.filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
|
||||
.filter(predicateDefinition -> !filterIgnorePropertiesConfig.getSwaggerProviders().contains(routeDefinition.getId()))
|
||||
.forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
|
||||
predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
|
||||
.replace("/**", API_URI)))));
|
||||
.filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
|
||||
.filter(predicateDefinition -> !filterIgnorePropertiesConfig.getSwaggerProviders().contains(routeDefinition.getId()))
|
||||
.forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
|
||||
predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
|
||||
.replace("/**", API_URI)))));
|
||||
|
||||
return resources.stream().sorted(Comparator.comparing(SwaggerResource::getName))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private SwaggerResource swaggerResource(String name, String location) {
|
||||
|
||||
+10
-2
@@ -18,6 +18,7 @@
|
||||
package com.pig4cloud.pigx.gateway.filter;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.gateway.config.SwaggerProvider;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -73,9 +74,16 @@ public class PigxRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
.build();
|
||||
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI());
|
||||
|
||||
// 3. 支持swagger添加X-Forwarded-Prefix header
|
||||
String path = request.getURI().getPath();
|
||||
if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
|
||||
return chain.filter(exchange.mutate().request(newRequest).build());
|
||||
}
|
||||
String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
|
||||
return chain.filter(exchange.mutate()
|
||||
.request(newRequest.mutate()
|
||||
.build()).build());
|
||||
.request(newRequest.mutate()
|
||||
.header(HEADER_NAME, basePath)
|
||||
.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ImageCodeHandler implements HandlerFunction<ServerResponse> {
|
||||
// 转换流信息写出
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||
try {
|
||||
ImageIO.write(image, "jpeg", os);
|
||||
ImageIO.write(image, MediaType.IMAGE_JPEG.getType(), os);
|
||||
} catch (IOException e) {
|
||||
log.error("ImageIO write err", e);
|
||||
return Mono.error(e);
|
||||
|
||||
Reference in new issue
Block a user