-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf($Starter): reduce unnecessary access log
reduce unnecessary access log BREAKING CHANGE: reduce unnecessary access log
- Loading branch information
Johnny Miller (锺俊)
committed
Dec 22, 2020
1 parent
bd1e5b3
commit 7e8a816
Showing
10 changed files
with
229 additions
and
5 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
69 changes: 69 additions & 0 deletions
69
.../com/jmsoftware/maf/muscleandfitnessserverspringbootstarter/configuration/IgnoredUrl.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,69 @@ | ||
package com.jmsoftware.maf.muscleandfitnessserverspringbootstarter.configuration; | ||
|
||
import com.google.common.collect.Lists; | ||
import lombok.Data; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.Pattern; | ||
import java.util.List; | ||
|
||
/** | ||
* <h1>IgnoredUrl</h1> | ||
* <p> | ||
* Ignored URL configuration. | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com | ||
* @date 5/2/20 11:41 PM | ||
**/ | ||
@Data | ||
public class IgnoredUrl { | ||
private interface Constant { | ||
String URL_REGEXP = "^(/[a-z0-9]+-?[a-z0-9]*|/\\*{1,2})*(/[a-z0-9]+\\.[a-z0-9]+)?$"; | ||
} | ||
|
||
/** | ||
* Ignored URL pattern. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> pattern = Lists.newArrayList(); | ||
/** | ||
* Ignored GET request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> get = Lists.newArrayList(); | ||
/** | ||
* Ignored POST request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> post = Lists.newArrayList(); | ||
/** | ||
* Ignored DELETE request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> delete = Lists.newArrayList(); | ||
/** | ||
* Ignored PUT request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> put = Lists.newArrayList(); | ||
/** | ||
* Ignored HEAD request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> head = Lists.newArrayList(); | ||
/** | ||
* Ignored PATCH request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> patch = Lists.newArrayList(); | ||
/** | ||
* Ignored OPTIONS request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> options = Lists.newArrayList(); | ||
/** | ||
* Ignored TRACE request. | ||
*/ | ||
@Valid | ||
private List<@Pattern(regexp = Constant.URL_REGEXP) String> trace = Lists.newArrayList(); | ||
} |
75 changes: 75 additions & 0 deletions
75
...msoftware/maf/muscleandfitnessserverspringbootstarter/configuration/MafConfiguration.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,75 @@ | ||
package com.jmsoftware.maf.muscleandfitnessserverspringbootstarter.configuration; | ||
|
||
import cn.hutool.core.util.ObjectUtil; | ||
import lombok.Data; | ||
import lombok.val; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.validation.annotation.Validated; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import java.util.ArrayList; | ||
|
||
/** | ||
* <h1>CustomConfiguration</h1> | ||
* <p>Custom configurations which are written in .yml files, containing a variety of fragmentary configs. Such as, | ||
* Druid login info, web security switch, web log and so on.</p> | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com | ||
* @date 2019-03-23 14:24 | ||
**/ | ||
@Data | ||
@Validated | ||
@Component | ||
@ConfigurationProperties(prefix = "maf.configuration") | ||
public class MafConfiguration { | ||
/** | ||
* <p>The username of super user who has no restriction to access any system's resources.</p> | ||
* <p><strong>ATTENTION</strong>: The value of username of super user must be equal to the value that is | ||
* persistent in database.</p> | ||
*/ | ||
@NotBlank | ||
private String superUser = "admin"; | ||
/** | ||
* Ignore URLs | ||
*/ | ||
@Valid | ||
private IgnoredUrl ignoredUrl; | ||
/** | ||
* <p>Web security feature switch. Default is false.</p> | ||
* true - disable web security; false - enable web security. | ||
*/ | ||
@NotNull | ||
private Boolean webSecurityDisabled = false; | ||
/** | ||
* Web request log switch. Default is false. | ||
* <p> | ||
* true - disable web request log; false - enable web request log. | ||
*/ | ||
@NotNull | ||
private Boolean webRequestLogDisabled = false; | ||
|
||
/** | ||
* Flatten ignored urls string [ ]. | ||
* | ||
* @return the string [ ] | ||
*/ | ||
public String[] flattenIgnoredUrls() { | ||
if (ObjectUtil.isNull(ignoredUrl)) { | ||
return new String[0]; | ||
} | ||
val flattenIgnoredUrls = new ArrayList<String>(); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getGet()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getPost()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getDelete()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getPut()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getHead()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getPatch()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getOptions()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getTrace()); | ||
flattenIgnoredUrls.addAll(ignoredUrl.getPattern()); | ||
return flattenIgnoredUrls.toArray(new String[0]); | ||
} | ||
} |
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
Empty file.
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