Skip to content

Koooooo-7/Kono

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

70 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Kono

πŸ’Š A simplified lightweight restful web framework.

When I used lots of out-of-box stuff, I wanna create something by myself, it does not matter whether it is fellowing the trending right now. I just wanna integrate those classic features from different languages/frameworks in my mind to one place, thus Kono is here, which is a simplified lightweight web framework.

✨ Features

  • Automatically route

    It will automatically generate the route based on the controller and methods.

  • Dynamical request support

    You can use one method to support both GET and POST requests.

  • Flexible acquire parameters

    There is more flexible way to acquire request parameters, and support parameter preprocessing.

  • Streaming responses

    Using the builder way to return your responses and build your own fully response.

πŸ“ Usage

Let us have a look how it works easily. (More details see the samples in project.)

Create an IndexController supports the requests.

  • GET /index/user
  • POST /index/user
// the default root route will be /index
public class IndexController extends BaseController {

    // both support the GET and POST request to /index/user
    public void user() {
        // get the specific request parameter
        Optional<String> user = this.getRequest().get("user", (parameter) -> {
            // you could do some thing before you get the parameter, such as set a filter;
            return parameter;
        });
        Map<String, Object> map = new HashMap<>();
        map.put("Koy", "Hello World!");
        map.put(user.orElseGet(() -> "Anonymous"), "Kono!");
        this.getResponse().send(map).json();
    }
    
    // only support the GET request to /index/user, the specific request type method has higher priority.
    public void getUser(){
        Optional<String> user = this.getRequest().get("user");
        Map<String, Object> map = new HashMap<>();
        map.put("Koy2", "Hello World!2");
        map.put(user.orElseGet(() -> "Anonymous2"), "Kono!2");
        this.getResponse().send(map).json();
    }
}

πŸ’‘ Reference

Thanks to those projects which inspire me and give me references a lot. (and there will get more and more)

SpringBoot - A popular, wonderful and elegant web framework in Java.

Laravel - A PHP framework for web artisans.

ThinkPHP - A easy to use PHP framework.

Django - The Web framework for perfectionists with deadlines in Python.

JOOQ - A fancy ORM lib to write SQL in Java.

πŸ“ƒ LICENSE

Apache-2.0 License Β©Koy

About

πŸ’Š A simplified lightweight restful web framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages