33 Star 39 Fork 15

liyongyao / light

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
liyongyao 提交于 2016-03-21 14:58 . Update README.md

一、快速入门

1.简单配置 resources下server-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<params>
		<param name="server.netty.port" value="11000" /><!--http服务监听端口-->
		<param name="server.intf.bind" value="com.lion.httpapi.api" /><!--api类包路径-->
		<param name="server.max.thread" value="100" /><!--最大并发数量,默认100-->
	</params>
</root>

2.查看test包下示例:

@HttpInterface 注解表示公开该类的方法 @HttpPath 注解表示路径,例如:

@HttpInterface
@HttpPath("/demo")
public class DemoAPI {
	
	@HttpPath("/helloString")
	public void helloString(ApiRequest request, ApiResponse response) {
		DemoModel data = request.getData(DemoModel.class);
		response.setData("hello "+data.getName());
	}

	……
}

void helloString(ApiRequest request, ApiResponse response) 方法的请求路径为/demo/helloString

二、约定 api方法的写法是固定的 public void methodName(ApiRequest request, ApiResponse response)

三、启动服务 new HttpServer().start();

Java
1
https://gitee.com/liyongyao/light.git
git@gitee.com:liyongyao/light.git
liyongyao
light
light
master

搜索帮助