1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-24 08:25:23 +00:00
v2fly/proxy/handler_cache.go
Darien Raymond e7aaba0c30
refactor
2017-07-25 23:12:54 +02:00

34 lines
766 B
Go

package proxy
import (
"context"
"v2ray.com/core/common"
)
func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
handler, err := common.CreateObject(ctx, config)
if err != nil {
return nil, newError("failed to create inbound handler").Base(err)
}
switch h := handler.(type) {
case Inbound:
return h, nil
default:
return nil, newError("not a InboundHandler")
}
}
func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) {
handler, err := common.CreateObject(ctx, config)
if err != nil {
return nil, newError("failed to create outbound handler").Base(err)
}
switch h := handler.(type) {
case Outbound:
return h, nil
default:
return nil, newError("not a OutboundHandler")
}
}