π 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.
-
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
andPOST
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.
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();
}
}
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.
Apache-2.0 License Β©Koy