Based on Java8
+ Netty4
to create lightweight, high-performance, simple and elegant Web framework 😋
Spend 1 hour to learn it to do something interesting, a Spring in addition to the framework of the best choice.
🐾 Quick Start | 📘 Blade In Action | 🎬 Video Tutorial | 🌚 Contribution | 💰 Donate | 🇨🇳 简体中文
Blade
is a pursuit of simple, efficient Web framework, so that JavaWeb
development even more powerful, both in performance and flexibility.
If you like to try something interesting, I believe you will love it.
If you think this item is good can star support or donate it 😊
- A new generation of MVC frameworks that do not depend on more libraries
- Get rid of SSH's bloated, modular design
- source less than
500kb
, learning is also simple - Restful style routing design
- template engine support, view development more flexible
- high performance, 100 concurrent tps 6w/s
- Run the
JAR
package to open the web service - Streaming API style
- supports plug-in extensions
- support webjars resources
- built-in a variety of commonly used middleware
- Built-in JSON output
- JDK8 +
» Simplicity: The design is simple, easy to understand and doesn't introduce many layers between you and the standard library. The goal of this project is that the users should be able to understand the whole framework in a single day.
» Elegance: blade
supports the RESTful style routing interface, has no invasive interceptors and provides the writing of DSL grammar.
» Easy deploy: support maven
package jar
file running.
Grab via Maven
:
<dependency>
<groupId>com.bladejava</groupId>
<artifactId>blade-mvc</artifactId>
<version>2.0.2</version>
</dependency>
or Gradle
:
compile 'com.bladejava:blade-mvc:2.0.2'
Write main
method, lets Hello World
:
public static void main(String[] args) {
Blade.me().get("/", (req, res) -> {
res.text("Hello Blade");
}).start();
}
Using browser open http://localhost:9000 so you can see the first Blade
application!
public static void main(String[] args) {
// Create Blade,using GET、POST、PUT、DELETE
Blade.me()
.get("/user/21", getting)
.post("/save", posting)
.delete("/remove", deleting)
.put("/putValue", putting)
.start();
}
public static void main(String[] args) {
Blade blade = Blade.me();
// Create a route: /user/:uid
blade.get("/user/:uid", (request, response) -> {
Integer uid = request.pathInt("uid");
response.text("uid : " + uid);
});
// Create two parameters route
blade.get("/users/:uid/post/:pid", (request, response) -> {
Integer uid = request.pathInt("uid");
Integer pid = request.pathInt("pid");
String msg = "uid = " + uid + ", pid = " + pid;
response.text(msg);
});
// Start blade
blade.start();
}
public static void main(String[] args) {
Blade.me().get("/user", ((request, response) -> {
Optional<Integer> ageOptional = request.queryInt("age");
ageOptional.ifPresent(age -> System.out.println("age is:" + age));
})).start();
}
public void upload(@MultipartParam FileItem fileItem){
byte[] data = fileItem.getData();
// Save the temporary file to the specified path
Files.write(Paths.get(filePath), data);
}
Or
public void upload(Request request){
request.fileItem("img").ifPresent(fileItem -> {
byte[] data = fileItem.getData();
// Save the temporary file to the specified path
Files.write(Paths.get(filePath), data);
});
}
public static void main(String[] args) {
// All requests are exported before execution before
Blade.me().before("/*", (request, response) -> {
System.out.println("before...");
}).start();
}
How easy it all looks, but the features above are the tip of the iceberg, and there are more surprises to see in the documentation and sample projects:
- Blog System:https://github.com/otale/tale
- Community Application:https://github.com/junicorn/roo
- Pictures social:https://github.com/biezhi/nice
- SS Panel:https://github.com/biezhi/ss-panel
- Blog:http://biezhi.me
- Mail: [email protected]
Thank you very much for the developers to help in the project, if you are willing to contribute, welcome!
Please see Apache License