-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
115 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ng-boot-starter/src/main/java/com/yuebaix/pangu/ready/logbook/PanGuLogbookBodyFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.yuebaix.pangu.ready.logbook; | ||
|
||
import com.yuebaix.pangu.ready.PanGuReadyStarterConst; | ||
import org.zalando.logbook.BodyFilter; | ||
import org.zalando.logbook.json.JsonBodyFilters; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* only works on all levels inside the json tree and with string values | ||
*/ | ||
public class PanGuLogbookBodyFilter implements BodyFilter { | ||
@Override | ||
public String filter(@Nullable String contentType, String body) { | ||
final Set<String> properties = new HashSet<>(PanGuLogbookConfigHolder.getObfuscateBodyParams()); | ||
return JsonBodyFilters.replaceJsonStringProperty(properties, PanGuReadyStarterConst.LOGBOOK_OBFUSCATE_CNT).filter(contentType, body); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...-boot-starter/src/main/java/com/yuebaix/pangu/ready/logbook/PanGuLogbookConfigHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.yuebaix.pangu.ready.logbook; | ||
|
||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class PanGuLogbookConfigHolder { | ||
private static Set<String> obfuscateBodyParams = Collections.emptySet(); | ||
|
||
static void set(PanGuLogbookProperties delayValue) { | ||
if (delayValue != null && !CollectionUtils.isEmpty(delayValue.getObfuscateBodyParams())) { | ||
obfuscateBodyParams = new HashSet<>(delayValue.getObfuscateBodyParams()); | ||
} | ||
} | ||
|
||
public static Set<String> getObfuscateBodyParams() { | ||
return obfuscateBodyParams; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ng-boot-starter/src/main/java/com/yuebaix/pangu/ready/logbook/PanGuLogbookProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.yuebaix.pangu.ready.logbook; | ||
|
||
import com.yuebaix.pangu.ready.PanGuReadyStarterConst; | ||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.util.List; | ||
|
||
@ConfigurationProperties(prefix = PanGuReadyStarterConst.PAN_GU_READY_STARTER_LOGBOOK_PREFIX) | ||
@Data | ||
public class PanGuLogbookProperties { | ||
private List<String> obfuscateBodyParams; | ||
|
||
@PostConstruct | ||
public void init() { | ||
PanGuLogbookConfigHolder.set(this); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...spring-boot-starter/src/main/java/com/yuebaix/pangu/ready/logbook/PanGuLogbookWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.yuebaix.pangu.ready.logbook; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.zalando.logbook.Correlation; | ||
import org.zalando.logbook.HttpLogWriter; | ||
import org.zalando.logbook.Precorrelation; | ||
|
||
import java.io.IOException; | ||
|
||
@Slf4j | ||
public class PanGuLogbookWriter implements HttpLogWriter { | ||
@Override | ||
public void write(Precorrelation precorrelation, String request) throws IOException { | ||
log.info(request); | ||
} | ||
|
||
@Override | ||
public void write(Correlation correlation, String response) throws IOException { | ||
log.info(response); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...y-spring-boot-starter/src/main/resources/META-INF/services/org.zalando.logbook.BodyFilter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.yuebaix.pangu.ready.logbook.PanGuLogbookBodyFilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters