2023-03-01 21:06:59 +08:00
|
|
|
# http-gateway
|
|
|
|
|
2023-03-01 21:50:09 +08:00
|
|
|
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)
|
|
|
|
```
|