smart-http 1.0.10 发布,7行代码便可运行的HTTP服务器

smart-http

smart-http 是一款比较简易的 http服务器,其通信内核采用了smart-socket最新版v1.4.4

也正因使用了 smart-socket,该服务器的性能表现还是非常不错的,在本人的4核CPU下能跑出73W+的 qps。

smart-socket 的每次性能测试都是基于该服务器进行的,相信 smart-http 的表现不会让您失望。

功能列表

  1. 支持GET、POST的HTTP请求。
  2. 提供了URL路由组件,可以快速搭建一套静态服务器。
  3. 支持部分RFC2612规范,后续会逐渐完善。
  4. 支持Https协议,由smart-socket为其赋能。
  5. 具备文件上传的能力。

快速体验

  1. 在您的Maven工程中引入smart-http依赖。
    <dependency>
        <groupId>org.smartboot.http</groupId>
        <artifactId>smart-http-parent</artifactId>
        <version>1.0.10</version>
        <type>pom</type>
    </dependency>
  2. 拷贝以下代码并启动。
    public class SimpleSmartHttp {
        public static void main(String[] args) {
            HttpBootstrap bootstrap = new HttpBootstrap();
            bootstrap.pipeline().next(new HttpHandle() {
                public void doHandle(HttpRequest request, HttpResponse response) throws IOException {
                    response.write("hello world".getBytes());
                }
            });
            bootstrap.setPort(8080).start();
        }
    }
  3. 浏览器访问:http://localhost:8080/

项目内还提供了静态文件服务器的示例,欢迎入坑体验。

猜你喜欢

转载自www.oschina.net/news/111049/smart-http-1-0-10-released