便携式纯JavaScript ES6 HTTP库:eshttp

loele 9年前

eshttp是一个便携式纯JavaScript ES6 HTTP库

设计目标:

  • 纯JavaScript (ES6)
  • high-performance and low-level, no stream abstractions
  • portable, multiple backends support (Node/other platforms)
  • fetch API frontend support

用法

Requires ES6 (io.js). Example web server using eshttp:

'use strict';  let eshttp = require('eshttp');  let HTTPServer = eshttp.HTTPServer;  let HTTPResponse = eshttp.HTTPResponse;    let server = new HTTPServer();  let response = new HTTPResponse(200, { 'x-header': 'value' }, 'hello');    server.onrequest = function(request) {    request.respondWith(response);  };    server.listen(8080);  console.log('listening to port 8080');

项目主页:http://www.open-open.com/lib/view/home/1438608868958