33 lines
604 B
Markdown
33 lines
604 B
Markdown
# 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)
|
|
``` |