GitHub - TobeDeveloper/nettyhttp: Netty mvc framework.
source link: https://github.com/TobeDeveloper/nettyhttp
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Http server and mvc framework with netty.
Used 3-rd party libraries:
- Netty
- Fastjson
- Freemarker
- Logback
- Owner
- Apache commons
Basic workflow:
Core config:
The config.properties
need to be provided, router.basePackage
should be included in this file. Then add the NettyRequestDispatcher
to your channel pipeline.
Example:
@Router
public class BasicRouter {
@Action(value = "/act", method = {RequestMethod.GET})
public Response act(RequestParam param) {
Response response = new JsonResponse();
response.put("date", new Date());
response.put("name", "Michael Yan");
System.out.println("Query params:" + param.getInt("id"));
return response;
}
@Action(value = "/post", method = {RequestMethod.POST})
public Response testPost(RequestParam param) {
Response response = new JsonResponse();
response.put("param", param);
response.put("date", new Date().toString());
return response;
}
@Action(value = "/view", method = {RequestMethod.POST})
public Response testView(RequestParam param) {
Response response = new HtmlResponse("test");
response.put("data", "server data");
response.put("strings", new String[]{"abc", "dfr", "klo"});
// response.setHtmlContent("<h1>Sample html content.</h1>");
return response;
}
}
Now, we only support GET/POST method, response data type will include plain txt/json/html, html template engine: freemarker.
Recommend
-
55
Spring MVC helps in building flexible and loosely coupled web applications. The Model-view-controller design pattern helps in seperating the business logic, presentation logic, and navigation logic. Models
-
3
December 17, 2015 Rediscovering MVC and How to Write without a Framework If you’ve paid much attention to front-end development in the last fe...
-
4
Migrate to ASP.NET Core MVC from ASP.NET Framework MVC 16 minute read .NET has been around for a while and has had many versions. We...
-
2
Our team has been working with serverless applications for two years now. It has changed the way our team deploys and operates applications. We no longer have to worry about provisioning servers and ensuring they are up. With AWS Lambda, we j...
-
5
Deondazy Core PHP MVC Framework Core is a simple light weight PHP MVC Framework, built to use for my PHP projects where Laravel and other PHP frameworks have way too much for my needs. Core has a simple Router, User Authe...
-
6
Reactor Netty Reactor Netty offers non-blocking and backpressure-ready TCP/HTTP/UDP clients & servers based on Netty framework. Getting it Rea...
-
74
前言看了下上篇博客的发表时间到这篇博客,竟然过了11个月,罪过,罪过。这一年时间也是够折腾的,年初离职跳槽到鹅厂,单独负责一个社区项目,忙的天昏地暗,忙的差不多了,转眼就到了7月。 七月流火,心也跟着燥热起来了,眼瞅着移动端这发展趋势从05年开始就一...
-
65
-
76
你真的理解了 MVC, MVP, MVVM 吗?
-
47
Spring MVC 温故而知新:从零开始
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK