Skip to content

Commit 02ddc58

Browse files
authored
Merge pull request lets-blade#251 from lets-blade/dev
Dev
2 parents 2a0dd9f + 781e30e commit 02ddc58

48 files changed

Lines changed: 2462 additions & 955 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ If you think this item is good can [star](https://github.com/biezhi/blade/starga
3939
* [x] High performance, 100 concurrent qps 14w/s
4040
* [x] Run the `JAR` package to open the web service
4141
* [x] Streaming API style
42+
* [x] `CSRF` and `XSS` defense
43+
* [x] `Basic Auth` and `Authorization`
4244
* [x] Supports plug-in extensions
4345
* [x] Support webjars resources
4446
* [x] Based on `cron` expression of tasks
@@ -62,7 +64,7 @@ Create a basic `Maven` project
6264
<dependency>
6365
<groupId>com.bladejava</groupId>
6466
<artifactId>blade-mvc</artifactId>
65-
<version>2.0.8-R3</version>
67+
<version>2.0.8.RELEASE</version>
6668
</dependency>
6769
```
6870

@@ -71,7 +73,7 @@ Create a basic `Maven` project
7173
or `Gradle`:
7274

7375
```sh
74-
compile 'com.bladejava:blade-mvc:2.0.8-R3'
76+
compile 'com.bladejava:blade-mvc:2.0.8.RELEASE'
7577
```
7678

7779
Write `main` method, try `Hello World`

README_CN.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
* [x] 模板引擎支持,视图开发更灵活
3838
* [x] 高性能,100并发下qps 14w/s
3939
* [x] 运行 `JAR` 包即可开启 web 服务
40+
* [x] 支持 `CSRF``XSS` 防御
41+
* [x] 支持 `BasicAuth` 和权限管理
4042
* [x] 流式API风格
4143
* [x] 支持插件扩展
4244
* [x] 支持 webjars 资源
@@ -61,7 +63,7 @@
6163
<dependency>
6264
<groupId>com.bladejava</groupId>
6365
<artifactId>blade-mvc</artifactId>
64-
<version>2.0.8-R3</version>
66+
<version>2.0.8.RELEASE</version>
6567
</dependency>
6668
```
6769

@@ -70,7 +72,7 @@
7072
或者 `Gradle`:
7173

7274
```sh
73-
compile 'com.bladejava:blade-mvc:2.0.8-R3'
75+
compile 'com.bladejava:blade-mvc:2.0.8.RELEASE'
7476
```
7577

7678
编写 `main` 函数写一个 `Hello World`

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'eclipse'
44
apply plugin: 'idea'
55

66
group = 'com.bladejava'
7-
version = '2.0.8-R1'
7+
version = '2.0.8-RELEASE'
88

99
description = 'blade-mvc'
1010

@@ -20,7 +20,7 @@ tasks.withType(JavaCompile) {
2020
}
2121

2222
def bladeAsmVersion = '0.0.1'
23-
def bladeLogVersion = '0.1.3'
23+
def bladeLogVersion = '0.1.5'
2424
def junitVersion = '4.12'
2525
def slf4jApiVersion = '1.7.21'
2626
def nettyVersion = '4.1.25.Final'

gradlew.bat

Lines changed: 84 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.bladejava</groupId>
77
<artifactId>blade-mvc</artifactId>
8-
<version>2.0.8-R3</version>
8+
<version>2.0.8.RELEASE</version>
99
<packaging>jar</packaging>
1010

1111
<name>blade</name>
@@ -37,8 +37,8 @@
3737
<junit.version>4.12</junit.version>
3838
<slf4j-api.version>1.7.25</slf4j-api.version>
3939
<netty.version>4.1.25.Final</netty.version>
40-
<blade-asm.version>0.0.1</blade-asm.version>
41-
<blade-log.version>0.1.4</blade-log.version>
40+
<blade-asm.version>0.0.2-SNAPSHOT</blade-asm.version>
41+
<blade-log.version>0.1.5</blade-log.version>
4242
<gson.version>2.8.5</gson.version>
4343
<bootstrap.version>4.1.0</bootstrap.version>
4444
<mockito.version>1.10.19</mockito.version>
@@ -52,7 +52,6 @@
5252
<groupId>org.slf4j</groupId>
5353
<artifactId>slf4j-api</artifactId>
5454
<version>${slf4j-api.version}</version>
55-
<scope>provided</scope>
5655
</dependency>
5756

5857
<dependency>

src/main/java/com/blade/Blade.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,11 @@ public Blade devMode(boolean devMode) {
417417
return this;
418418
}
419419

420-
public boolean isAutoRefreshDir(){
421-
return environment.get(ENV_KEY_AUTO_REFRESH_DIR).isPresent();
420+
public boolean isAutoRefreshDir() {
421+
return environment.get(ENV_KEY_AUTO_REFRESH_DIR).isPresent();
422422
}
423423

424-
public void setAutoRefreshDir(String dir){
424+
public void setAutoRefreshDir(String dir) {
425425
environment.set(ENV_KEY_AUTO_REFRESH_DIR, dir);
426426
}
427427

@@ -649,7 +649,7 @@ public Blade disableSession() {
649649
return this;
650650
}
651651

652-
public Blade watchEnvChange(boolean watchEnvChange){
652+
public Blade watchEnvChange(boolean watchEnvChange) {
653653
this.environment.set(ENV_KEY_APP_WATCH_ENV, watchEnvChange);
654654
return this;
655655
}
@@ -711,29 +711,29 @@ public Blade start(Class<?> bootClass, @NonNull String address, int port, String
711711
thread.start();
712712
started = true;
713713

714-
Thread resourceFilesRefreshThread = new Thread(()-> {
714+
Thread resourceFilesRefreshThread = new Thread(() -> {
715715

716716
try {
717717
FileChangeDetector fileChangeDetector = new FileChangeDetector(environment.get(ENV_KEY_AUTO_REFRESH_DIR).get());
718-
fileChangeDetector.processEvent( (event , filePath) ->{
718+
fileChangeDetector.processEvent((event, filePath) -> {
719719
try {
720720
//TODO: add support for Create and Delete
721-
if(event.equals(StandardWatchEventKinds.ENTRY_MODIFY)) {
721+
if (event.equals(StandardWatchEventKinds.ENTRY_MODIFY)) {
722722
Path destPath = FileChangeDetector.getDestPath(filePath, environment);
723723
Files.copy(filePath, destPath, StandardCopyOption.REPLACE_EXISTING);
724724
}
725-
}catch (IOException e){
725+
} catch (IOException e) {
726726
log.error("Exception when trying to copy updated file");
727727
startupExceptionHandler.accept(e);
728728
}
729729
});
730-
}catch (IOException e){
730+
} catch (IOException e) {
731731
startupExceptionHandler.accept(e);
732732
}
733733

734734
});
735735

736-
if (devMode() && isAutoRefreshDir()){
736+
if (devMode() && isAutoRefreshDir()) {
737737
log.info("auto refresh is enabled");
738738
resourceFilesRefreshThread.start();
739739
}
@@ -840,6 +840,18 @@ public Blade threadName(String threadName) {
840840
return this;
841841
}
842842

843+
/**
844+
* Set context path, default is "/"
845+
*
846+
* @param contextPath context path
847+
* @return return blade instance
848+
* @since 2.0.8-RELEASE
849+
*/
850+
public Blade contextPath(String contextPath) {
851+
environment.set(ENV_KEY_CONTEXT_PATH, contextPath);
852+
return this;
853+
}
854+
843855
/**
844856
* Get WebSocket Handler
845857
*

src/main/java/com/blade/exception/ValidatorException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
public class ValidatorException extends RuntimeException {
2727

2828
@Getter
29-
private String code;
29+
private Integer code;
3030

31-
public ValidatorException(String code, String message) {
31+
public ValidatorException(Integer code, String message) {
3232
super(message);
3333
this.code = code;
3434
}

0 commit comments

Comments
 (0)