🔖 V1.3.1. support zuul dynamic groovy filters

This commit is contained in:
冷冷 2018-11-15 15:33:22 +08:00
parent bdef2679d0
commit cf5328c30b
16 changed files with 94 additions and 37 deletions

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-auth</artifactId> <artifactId>pig-auth</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-auth</name> <name>pig-auth</name>
@ -31,14 +31,14 @@
<parent> <parent>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<!--oauth2.0--> <!--oauth2.0-->
<dependency> <dependency>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-common</name> <name>pig-common</name>
@ -31,7 +31,7 @@
<parent> <parent>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-config</artifactId> <artifactId>pig-config</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-config</name> <name>pig-config</name>
@ -31,7 +31,7 @@
<parent> <parent>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-eureka</artifactId> <artifactId>pig-eureka</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-eureka</name> <name>pig-eureka</name>
@ -31,7 +31,7 @@
<parent> <parent>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-gateway</artifactId> <artifactId>pig-gateway</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-gateway</name> <name>pig-gateway</name>
@ -31,14 +31,14 @@
<parent> <parent>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<!--zuul网关--> <!--zuul网关-->
<dependency> <dependency>

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.github.pig.gateway.component.linster;
import com.netflix.zuul.FilterFileManager;
import com.netflix.zuul.FilterLoader;
import com.netflix.zuul.groovy.GroovyCompiler;
import com.netflix.zuul.groovy.GroovyFileFilter;
import com.netflix.zuul.monitoring.MonitoringHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
/**
* @author lengleng
* @date 2018/11/15
* <p>
* 动态filter 初始化配置
*/
@Slf4j
@Component
@ConditionalOnProperty("zuul.groovy.path")
public class GroovyLoadInitListener {
@Value("${zuul.groovy.path}")
private String groovyPath;
@EventListener(value = {EmbeddedServletContainerInitializedEvent.class})
public void init() {
MonitoringHelper.initMocks();
FilterLoader.getInstance().setCompiler(new GroovyCompiler());
FilterFileManager.setFilenameFilter(new GroovyFileFilter());
try {
FilterFileManager.init(10, groovyPath);
} catch (Exception e) {
log.error("初始化网关Groovy 文件失败 {}", e);
}
log.warn("初始化网关Groovy 文件成功");
}
}

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-daemon-service</artifactId> <artifactId>pig-daemon-service</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-daemon-service</name> <name>pig-daemon-service</name>
@ -31,7 +31,7 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId> <artifactId>pig-modules</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<properties> <properties>
@ -43,7 +43,7 @@
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.xjzrc.spring.boot</groupId> <groupId>com.github.xjzrc.spring.boot</groupId>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-mc-service</artifactId> <artifactId>pig-mc-service</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-mc-service</name> <name>pig-mc-service</name>
@ -31,14 +31,14 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId> <artifactId>pig-modules</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<!--阿里大于--> <!--阿里大于-->
<dependency> <dependency>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-sso-client-demo</artifactId> <artifactId>pig-sso-client-demo</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-sso-client-demo</name> <name>pig-sso-client-demo</name>
@ -31,7 +31,7 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId> <artifactId>pig-modules</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-upms-service</artifactId> <artifactId>pig-upms-service</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-upms-service</name> <name>pig-upms-service</name>
@ -31,14 +31,14 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId> <artifactId>pig-modules</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<!--MySQL--> <!--MySQL-->
<dependency> <dependency>

View File

@ -20,13 +20,13 @@
<parent> <parent>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-modules</artifactId> <artifactId>pig-modules</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>pig-modules</name> <name>pig-modules</name>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-monitor</artifactId> <artifactId>pig-monitor</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-monitor</name> <name>pig-monitor</name>
@ -31,14 +31,14 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId> <artifactId>pig-visual</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<!--admin--> <!--admin-->
<dependency> <dependency>

View File

@ -23,7 +23,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-zipkin-db</artifactId> <artifactId>pig-zipkin-db</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-zipkin-db</name> <name>pig-zipkin-db</name>
@ -32,13 +32,13 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId> <artifactId>pig-visual</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.zipkin.java</groupId> <groupId>io.zipkin.java</groupId>

View File

@ -22,7 +22,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-zipkin-elk</artifactId> <artifactId>pig-zipkin-elk</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>pig-zipkin-elk</name> <name>pig-zipkin-elk</name>
@ -31,14 +31,14 @@
<parent> <parent>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId> <artifactId>pig-visual</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-common</artifactId> <artifactId>pig-common</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>

View File

@ -21,7 +21,7 @@
<groupId>com.github.pig</groupId> <groupId>com.github.pig</groupId>
<artifactId>pig-visual</artifactId> <artifactId>pig-visual</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>pig-visual</name> <name>pig-visual</name>
@ -30,7 +30,7 @@
<parent> <parent>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<groupId>com.github</groupId> <groupId>com.github</groupId>
<version>1.3.0</version> <version>1.3.1</version>
</parent> </parent>
<modules> <modules>

View File

@ -23,7 +23,7 @@
<groupId>com.github</groupId> <groupId>com.github</groupId>
<artifactId>pig</artifactId> <artifactId>pig</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<packaging>pom</packaging> <packaging>pom</packaging>