hx-http-server

Http Server HxCpp target
https://github.com/rainyt/http-server

To install, run:

haxelib install hx-http-server 0.0.4 

See using Haxelib in Haxelib documentation for more information.

README.md

HTTP Server

通过Haxe编写的HTTP服务器,基本功能已经准备好,正进入生产阶段。

语言

English

支持

RPC支持

带有常用的RPC接口,可参考test/RPCMain.hx

基础的HTTP服务功能

// 创建基础的HTTP侦听服务
var ip:String = "0.0.0.0";
var port = 5555;
var http = new HTTPServer(ip, port, true);
http.start();
http.onConnectRequest = (client) -> {
   client.send("hello world.");
};

基础路由功能

// 使用`addRoute`API可以轻松为请求添加路由
http.route.addRoute("/", (http) -> {
	trace("访问到了/路由", http.path);
	return true;
});

自定义路由服务

可参考test/CustomRoute.hx类的实现。

对象反射路由

通过一个对象,由http.macro.ReflectRouteMacro自动生成反射对象类,使它每个公开的方法都能够自动转换成路由方法,并遵循参数的可选不可选、参数名等。 同时,可以直接继承http.route.HTTPReflectCustomObject直接实现公开方法,请参考ReflectCustomObject。

HTTPS(未完成)

它需要一个证书测试,我还没有进行这项测试。

GET数据

通过client.param.get方法获得?后面的参数。

POST数据

已支持application/json以及application/x-www-form-urlencoded支持,可通过client.param.post获得。

HEADER头信息数据

通过client.param.header方法获得头信息参数。

数据后处理

通过httpServer.onResponseAfter接口处理最终输出的结果,可以在这里修改client.response.data参数处理最终输出结果。

Contributors
rainy
Version
0.0.4
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂