Giter VIP home page Giter VIP logo

blade's Introduction

Quick Start  |  Demo Project  |  Contribute  |  Donate  |  FAQ |  中文说明

Build Status maven-central License Gitter

What Is Blade?

Blade is a lightweight MVC framework. It is based on the principles of simplicity and elegance. If you like it, please star / fork. Thx 😊

Features

  • Lightweight: the code is simple and the structure is clear
  • RESTful style routing interface
  • Template engine support
  • High performance
  • Run with jar file
  • Fluent interface
  • Support plugin extension
  • Support webjars
  • JDK8+
  • Event mechanism

Overview

  • 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.

Get Start

To get started, first include the Blade library :

Grab via Maven

<dependency>
	<groupId>com.bladejava</groupId>
	<artifactId>blade-mvc</artifactId>
	<version>2.0.0</version>
</dependency>

or Gradle:

compile 'com.bladejava:blade-mvc:2.0.0'

Create Main method like this:

public static void main(String[] args) {
    Blade blade = Blade.me();
    blade.get("/", (req, res) -> {
        res.text("Hello Blade");
    }).start();
}

Run it and point your browser to http://localhost:9000. There you go, you've just created your first Blade app!

API Example

public static void main(String[] args) {
    Blade blade = Blade.of();
    blade.get("/user/21", getxxx);
    blade.post("/save", postxxx);
    blade.delete("/del/21", deletexxx);
    blade.put("/put", putxxx);
}

REST URL Parameters

public static void main(String[] args) {
    Blade blade = Blade.of();
    blade.get("/user/:uid", (request, response) -> {
		Integer uid = request.queryInt("uid").get();
		response.text("uid : " + uid);
	});
	
    blade.get("/users/:uid/post/:pid", (request, response) -> {
		Integer uid = request.queryInt("uid").get();
		Integer pid = request.queryInt("pid").get();
		String msg = "uid = " + uid + ", pid = " + pid;
		response.text(msg);
	});
	
    blade.start();
}

Form URL Parameters

public static void main(String[] args) {
    Blade blade = Blade.of();
    blade.get("/user", (request, response) -> {
		Integer uid = request.queryInt("uid").get();
		response.text("uid : " + uid);
	}).start(Application.class);
}

Upload File

public void upload_img(@MultipartParam FileItem fileItem){
    if(null != fileItem){
        File file = fileItem.getFile();
        String fileRealPath = "your upload file path!";
        nioTransferCopy(file, fileRealPath);
    }
}

Route Web Hook

public static void main(String[] args) {
    Blade blade = Blade.of();
    blade.before("/.*", (request, response) -> {
        System.out.println("before...");
    }).start();
}

You may refer to these examples for additional guidance:

Used Blade WebSite

Update

update log

Contact

Contributor

Thank you very much for the developers to help in the project, if you are willing to contribute, welcome!

Licenses

Please see Apache License

blade's People

Contributors

hellokaton avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.