Skip to content

Commit abbc9ec

Browse files
committed
release 2.1.1.RELEASE
1 parent 5fd0dc0 commit abbc9ec

File tree

10 files changed

+79
-19
lines changed

10 files changed

+79
-19
lines changed

README.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ Run with `Maven`:
6464
<dependency>
6565
<groupId>com.hellokaton</groupId>
6666
<artifactId>blade-core</artifactId>
67-
<version>2.1.1.BETA</version>
67+
<version>2.1.1.RELEASE</version>
6868
</dependency>
6969
```
7070

7171
or `Gradle`:
7272

7373
```sh
74-
compile 'com.hellokaton:blade-core:2.1.1.BETA'
74+
compile 'com.hellokaton:blade-core:2.1.1.RELEASE'
7575
```
7676

7777
Write the `main` method and the `Hello World`:
@@ -99,6 +99,7 @@ Open http://localhost:9000 in your browser to see your first `Blade` application
9999
- [**`Get Cookie`**](#get-cookie)
100100
- [**`Static Resource`**](#static-resource)
101101
- [**`Upload File`**](#upload-file)
102+
- [**`Download File`**](#download-file)
102103
- [**`Set Session`**](#set-session)
103104
- [**`Render To Browser`**](#render-to-browser)
104105
- [**`Render Response`**](#render-json)
@@ -397,8 +398,36 @@ public void upload(@Multipart FileItem fileItem){
397398
}
398399
```
399400

401+
## Download File
402+
403+
```java
404+
@GET(value = "/download", responseType = ResponseType.STREAM)
405+
public void download(Response response) throws IOException {
406+
response.write("abcd.pdf", new File("146373013842336153820220427172437.pdf"));
407+
}
408+
```
409+
410+
**If you want to preview certain files in your browser**
411+
412+
```java
413+
@GET(value = "/preview", responseType = ResponseType.PREVIEW)
414+
public void preview(Response response) throws IOException {
415+
response.write(new File("146373013842336153820220427172437.pdf"));
416+
}
417+
```
418+
400419
## Set Session
401420

421+
The session is disabled by default, you must enable the session.
422+
423+
```java
424+
Blade.create()
425+
.http(HttpOptions::enableSession)
426+
.start(Application.class, args);
427+
```
428+
429+
> 💡 It can also be enabled using a configuration file,`http.session.enabled=true`
430+
402431
```java
403432
public void login(Session session){
404433
// if login success
@@ -554,7 +583,7 @@ The `hello.html` template
554583
</html>
555584
```
556585

557-
[Render API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA/com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView-)
586+
[Render API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE/com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView-)
558587

559588
## Redirects
560589

@@ -565,7 +594,7 @@ public void redirectToGithub(RouteContext ctx){
565594
}
566595
```
567596

568-
[Redirect API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA/com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String-)
597+
[Redirect API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE/com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String-)
569598

570599
## Write Cookie
571600

@@ -577,7 +606,7 @@ public void writeCookie(RouteContext ctx){
577606
}
578607
```
579608

580-
[Cookie API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA/com/hellokaton/blade/mvc/http/Response.html#cookie-java.lang.String-java.lang.String-)
609+
[Cookie API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE/com/hellokaton/blade/mvc/http/Response.html#cookie-java.lang.String-java.lang.String-)
581610

582611
## Web Hook
583612

README_CN.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<dependency>
6161
<groupId>com.hellokaton</groupId>
6262
<artifactId>blade-core</artifactId>
63-
<version>2.1.1.BETA</version>
63+
<version>2.1.1.RELEASE</version>
6464
</dependency>
6565
```
6666

@@ -69,7 +69,7 @@
6969
或者 `Gradle`:
7070

7171
```sh
72-
compile 'com.hellokaton:blade-core:2.1.1.BETA'
72+
compile 'com.hellokaton:blade-core:2.1.1.RELEASE'
7373
```
7474

7575
编写 `main` 函数写一个 `Hello World`
@@ -98,6 +98,7 @@ public static void main(String[] args) {
9898
- [**`获取Cookie`**](#获取cookie)
9999
- [**`静态资源`**](#静态资源)
100100
- [**`上传文件`**](#上传文件)
101+
- [**`下载文件`**](#下载文件)
101102
- [**`设置会话`**](#设置会话)
102103
- [**`渲染到浏览器`**](#渲染到浏览器)
103104
- [**`渲染JSON`**](#渲染json)
@@ -396,8 +397,36 @@ public void upload(@Multipart FileItem fileItem){
396397
}
397398
```
398399

400+
## 下载文件
401+
402+
```java
403+
@GET(value = "/download", responseType = ResponseType.STREAM)
404+
public void download(Response response) throws IOException {
405+
response.write("abcd.pdf", new File("146373013842336153820220427172437.pdf"));
406+
}
407+
```
408+
409+
**如果你想在浏览器预览某些文件**
410+
411+
```java
412+
@GET(value = "/preview", responseType = ResponseType.PREVIEW)
413+
public void preview(Response response) throws IOException {
414+
response.write(new File("146373013842336153820220427172437.pdf"));
415+
}
416+
```
417+
399418
## 设置会话
400419

420+
默认情况不开启会话功能,首先要开启会话
421+
422+
```java
423+
Blade.create()
424+
.http(HttpOptions::enableSession)
425+
.start(Application.class, args);
426+
```
427+
428+
> 💡 也可以使用配置文件开启,`http.session.enabled=true`
429+
401430
```java
402431
public void login(Session session){
403432
// if login success
@@ -553,7 +582,7 @@ public static void main(String[] args) {
553582
</html>
554583
```
555584

556-
[Render API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA/com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView-)
585+
[Render API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE/com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView-)
557586

558587
## 重定向
559588

@@ -564,7 +593,7 @@ public void redirectToGithub(RouteContext ctx){
564593
}
565594
```
566595

567-
[Redirect API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA/com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String-)
596+
[Redirect API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE/com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String-)
568597

569598
## 写入Cookie
570599

@@ -576,7 +605,7 @@ public void writeCookie(RouteContext ctx){
576605
}
577606
```
578607

579-
[Cookie API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA/com/hellokaton/blade/mvc/http/Response.html#cookie-java.lang.String-java.lang.String-)
608+
[Cookie API](http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE/com/hellokaton/blade/mvc/http/Response.html#cookie-java.lang.String-java.lang.String-)
580609

581610
## 路由拦截
582611

blade-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.hellokaton</groupId>
77
<artifactId>blade</artifactId>
8-
<version>2.1.1.BETA</version>
8+
<version>2.1.1.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

blade-core/src/main/java/com/hellokaton/blade/mvc/BladeConst.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface BladeConst {
3131
int DEFAULT_SERVER_PORT = 9000;
3232
String DEFAULT_SERVER_ADDRESS = "0.0.0.0";
3333
String LOCAL_IP_ADDRESS = "127.0.0.1";
34-
String VERSION = "2.1.1.BETA";
34+
String VERSION = "2.1.1.RELEASE";
3535
String WEB_JARS = "/webjars/";
3636
String CLASSPATH = BladeKit.getCurrentClassPath();
3737
String HTTP_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";

blade-examples/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.hellokaton</groupId>
77
<artifactId>blade</artifactId>
8-
<version>2.1.1.BETA</version>
8+
<version>2.1.1.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>com.hellokaton</groupId>
2525
<artifactId>blade-security</artifactId>
26-
<version>2.1.1.BETA</version>
26+
<version>2.1.1.RELEASE</version>
2727
</dependency>
2828
<dependency>
2929
<groupId>org.projectlombok</groupId>

blade-examples/src/main/java/com/example/Application.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.hellokaton.blade.mvc.multipart.FileItem;
1515
import com.hellokaton.blade.mvc.ui.ResponseType;
1616
import com.hellokaton.blade.options.CorsOptions;
17+
import com.hellokaton.blade.options.HttpOptions;
1718
import com.hellokaton.blade.security.csrf.CsrfMiddleware;
1819
import com.hellokaton.blade.security.limit.LimitMiddleware;
1920
import com.hellokaton.blade.security.limit.LimitOptions;
@@ -81,7 +82,7 @@ public String verifyToken(Request req) {
8182
}
8283

8384
@GET(value = "/preview/:id", responseType = ResponseType.PREVIEW)
84-
public void preview(@PathParam String id, Response response) throws Exception {
85+
public void preview(@PathParam String id, Response response) throws IOException {
8586
response.write(new File("/Users/biezhi/Downloads/146373013842336153820220427172437.pdf"));
8687
}
8788

@@ -98,6 +99,7 @@ public static void main(String[] args) {
9899

99100
Blade.create()
100101
.cors(corsOptions)
102+
.http(HttpOptions::enableSession)
101103
// .use(new CsrfMiddleware())
102104
// .use(new LimitMiddleware(limitOptions))
103105
.listen().start(Application.class);

blade-kit/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.hellokaton</groupId>
77
<artifactId>blade</artifactId>
8-
<version>2.1.1.BETA</version>
8+
<version>2.1.1.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

blade-security/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>blade</artifactId>
77
<groupId>com.hellokaton</groupId>
8-
<version>2.1.1.BETA</version>
8+
<version>2.1.1.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

blade-websocket/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.hellokaton</groupId>
77
<artifactId>blade</artifactId>
8-
<version>2.1.1.BETA</version>
8+
<version>2.1.1.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.hellokaton</groupId>
77
<artifactId>blade</artifactId>
8-
<version>2.1.1.BETA</version>
8+
<version>2.1.1.RELEASE</version>
99
<packaging>pom</packaging>
1010

1111
<name>blade</name>

0 commit comments

Comments
 (0)