add design

This commit is contained in:
kingecg 2023-03-01 21:50:09 +08:00
parent 811ad934c0
commit 9ac9deaa8f
3 changed files with 56 additions and 0 deletions

View File

@ -1,2 +1,33 @@
# http-gateway # http-gateway
a lib for create gateway between and other protocol
interface
- create 创建http服务器app
- registryHandlerFactory 注册protocol处理器工厂
- app.registryPath
## HandlerFactory
一个函数或者拥有静态createHandler方法的class
工厂函数/createHandler方法签名
```typescript
interface HandlerFn {
(options: any): (req:Request,resp: Response)=>void
}
interface HandlerClass {
createHandler: HandlerFn
}
type HandlerFactory = HandlerFn | HandlerClass
```
## registryHandlerFactory
```typescript
registryHandlerFactory(type:string, HandlerFactory)
```

9
model/def.ts Normal file
View File

@ -0,0 +1,9 @@
interface HandlerFn {
(options: any): (req:Request,resp: Response)=>void
}
interface HandlerClass {
createHandler: HandlerFn
}
type HandlerFactory = HandlerFn | HandlerClass

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "http-gateway",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "ssh://git@git.pyer.club:2222/kingecg/http-gateway.git"
},
"keywords": [],
"author": "",
"license": "ISC"
}