Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

Latest commit

 

History

History
28 lines (22 loc) · 848 Bytes

README.md

File metadata and controls

28 lines (22 loc) · 848 Bytes

connect

该项目已经废弃,请用 https://github.com/nohosts/router 代替,router 不仅支持 connect 所有功能,还支持转发到集群等更多的功能

Nohost 内部处理请求转发的模块

安装

npm i --save @nohost/connect

用法

const { getRawHeaders, request, tunnel, upgrade } = require('@nohost/connect');

API

  1. const rawHeaders = getRawHeaders(req|res):还原请求或响应头大小写
  2. const svrRes = await request(req, res, options)
    • options: 可选,目标服务器的 IP(域名)及端口
    • req:请求对象
    • res: 响应对象
    • svrRes: 上游服务响应对象
  3. tunnel(req, options):代理隧道代理
  4. upgrade(req, options):转发 WebSocket 请求

例子

参考:https://github.com/nohosts/router/blob/master/lib/connect.js