在一个端口监听http和https
安装
npm install listen-one --save
使用
"use strict";var express = ;var app = ;var one = ; // 下载https证书的链接app; app; one; // 使用https链接one; one;
koa2使用示例见文件test/koa.test.js
api
- createServer(listener) : 创建服务器,同http.createServer
- listen(port,[callback]) : 监听端口
- port: 监听端口
- callback: 启动监听后回调
- https([conf]) : 启动https服务,必须在createServer之后才可以调用
- conf: 包括key和cert,https访问的密匙和公匙
- callback: 启动监听后的回调
- getCert() : 获取https证书(浏览器访问地址需要证书才可正常访问)
- close() : 停止监听端口
todo
- 启动http
- 启动https
- 下载https证书
- 停止监听端口
- express使用示例
- koa使用示例
- 停止监听时停止所有服务监听
- 增加debug调试内容
history
1.0.5
修复close后http和https服务器未关闭问题