示例#1
0
func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
	handler, err := common.CreateObject(ctx, config)
	if err != nil {
		return nil, err
	}
	switch h := handler.(type) {
	case Inbound:
		return h, nil
	default:
		return nil, errors.New("Proxy: Not a InboundHandler.")
	}
}
示例#2
0
func CreateAppFromConfig(ctx context.Context, config interface{}) (Application, error) {
	application, err := common.CreateObject(ctx, config)
	if err != nil {
		return nil, err
	}
	switch a := application.(type) {
	case Application:
		return a, nil
	default:
		return nil, errors.New("App: Not an application.")
	}
}
示例#3
0
func CreatePacketHeader(config interface{}) (PacketHeader, error) {
	header, err := common.CreateObject(context.Background(), config)
	if err != nil {
		return nil, err
	}
	switch h := header.(type) {
	case PacketHeader:
		return h, nil
	default:
		return nil, errors.New("Internet: Not a packet header.")
	}
}
示例#4
0
func CreateConnectionAuthenticator(config interface{}) (ConnectionAuthenticator, error) {
	auth, err := common.CreateObject(context.Background(), config)
	if err != nil {
		return nil, err
	}
	switch a := auth.(type) {
	case ConnectionAuthenticator:
		return a, nil
	default:
		return nil, errors.New("Internet: Not a ConnectionAuthenticator.")
	}
}