上海 响应式网站公司,wordpress 集成安装包,长沙网站设计服务,家乡网页设计作品欣赏文章目录 概述官网Hserver的理念特点原理图代码案例HelloWorld 概述
HServer是一个基于Netty开发网络扩展库.使用插件方式来扩展我们的业务 HServer提供 web,gateway,rpc 等插件 同时用户也可以自定义插件#xff0c;来完成各种各样的业务场景。 官网
https://gitee.com/HSe… 文章目录 概述官网Hserver的理念特点原理图代码案例HelloWorld 概述
HServer是一个基于Netty开发网络扩展库.使用插件方式来扩展我们的业务 HServer提供 web,gateway,rpc 等插件 同时用户也可以自定义插件来完成各种各样的业务场景。 官网
https://gitee.com/HServer/HServer
https://doc.hserver.top/#/
https://gitee.com/HServer Hserver的理念 极简、高性能、扩展强 极简 代码只有几百KB 高性能 使用Netty网络库作为核心比起传统的web容器性能高数十倍. 扩展强 预留了丰富的接口以及netty直接自定义协议 特点
简便易用5分钟即可掌握使用快速构建高效APITCP层上直接构建Restful风格路由设计Cron定时器Filter拦截器持久Queue队列HOOK/AOP组件Track链路跟踪组件Web Socket功能Mqtt WebSocketMqtt功能自定义协议Proxy 自由处理ApiDoc文档组件权限组件Plugin组件自由扩展HUM消息高性能高度自由度控制流量整形Netty 原生响应支持自己扩展 原理图 代码案例 HelloWorld 建立一个maven项目导入依赖 parentartifactIdhserver-parent/artifactIdgroupIdcn.hserver/groupIdversion最新版本/version
/parentdependencies
!-- 核心依赖--dependencyartifactIdhserver/artifactIdgroupIdcn.hserver/groupId/dependency
!-- web框架 --dependencyartifactIdhserver-plugin-web/artifactIdgroupIdcn.hserver/groupId/dependency
/dependencies
!-- 打包jar --
buildpluginspluginartifactIdhserver-plugin-maven/artifactIdgroupIdcn.hserver/groupId/plugin/plugins
/build 建立一个主函数 建立一个java包如 com.test 建立一个主函数 HServerBoot
public class WebApp {public static void main(String[] args) {HServerApplication.run(WebApp.class, 8888, args);}
}建立一个控制器 Controller
public class HelloController {GET(/test1)public JsonResult test() {return JsonResult.ok();}POST(/test2)public JsonResult b(HttpRequest request) {return JsonResult.ok().put(data, request.getRequestParams());}RequestMapping(value /get, method RequestMethod.GET)public JsonResult get() {return JsonResult.ok();}RequestMapping(value /post, method RequestMethod.POST)public JsonResult post(HttpRequest httpRequest) {return JsonResult.ok().put(data, httpRequest.getRequestParams());}/*** 模板测试* param httpResponse*/GET(/template)public void template(HttpResponse httpResponse) {User user new User();user.setAge(20);user.setName(xx);user.setSex(男);MapString, Object obj new HashMap();obj.put(user, user);
// httpResponse.sendTemplate(/admin/user/list.ftl, obj);httpResponse.sendTemplate(a.ftl, obj);}
}运行主函数访问8888端口即可