func NewSubscriberWithEndpoint(manipulator manipulate.Manipulator, endpoint string, recursive bool) manipulate.Subscriber {
	return NewSubscriber(manipulator, SubscriberOptionRecursive(recursive), SubscriberOptionEndpoint(endpoint))
}
NewSubscriberWithEndpoint returns a new subscription connecting to specific endpoint.
package maniphttp
import (
	"crypto/tls"
	"fmt"
	"net/http"
	"strings"
	"go.aporeto.io/manipulate"
	"go.aporeto.io/manipulate/internal/push"
)
type subscribeConfig struct {
	namespace           string
	credentialCookieKey string
	endpoint            string
	supportErrorEvents  bool
	recursive           bool
	tlsConfig           *tls.Config
}
func newSubscribeConfig(m *httpManipulator) subscribeConfig {
	return subscribeConfig{
		endpoint:  "events",
		namespace: m.namespace,
		tlsConfig: m.tlsConfig,
	}
}
type SubscriberOption func(*subscribeConfig)
func SubscriberOptionRecursive(recursive bool) SubscriberOption {
	return func(cfg *subscribeConfig) {
		cfg.recursive = recursive
	}
}
func SubscriberOptionNamespace(namespace string) SubscriberOption {
	return func(cfg *subscribeConfig) {
		cfg.namespace = namespace
	}
}
func SubscriberOptionEndpoint(endpoint string) SubscriberOption {
	return func(cfg *subscribeConfig) {
		cfg.endpoint = strings.TrimRight(strings.TrimLeft(endpoint, "/"), "/")
	}
}
func SubscriberSendCredentialsAsCookie(key string) SubscriberOption {
	return func(cfg *subscribeConfig) {
		cfg.credentialCookieKey = key
	}
}
func SubscriberOptionSupportErrorEvents() SubscriberOption {
	return func(cfg *subscribeConfig) {
		cfg.supportErrorEvents = true
	}
}
func NewSubscriber(manipulator manipulate.Manipulator, options ...SubscriberOption) manipulate.Subscriber {
	m, ok := manipulator.(*httpManipulator)
	if !ok {
		panic("You must pass a HTTP manipulator to maniphttp.NewSubscriber or maniphttp.NewSubscriberWithEndpoint")
	}
	cfg := newSubscribeConfig(m)
	for _, opt := range options {
		if opt == nil {
			panic("nil passed as subscriber option")
		}
		opt(&cfg)
	}
	if cfg.tlsConfig != nil {
		cfg.tlsConfig = cfg.tlsConfig.Clone()
		cfg.tlsConfig.NextProtos = nil
	}
	return push.NewSubscriber(
		fmt.Sprintf("%s/%s", m.url, cfg.endpoint),
		cfg.namespace,
		m.currentPassword(),
		m.registerRenewNotifier,
		m.unregisterRenewNotifier,
		cfg.tlsConfig,
		http.Header{
			"Content-Type": []string{string(m.encoding)},
			"Accept":       []string{string(m.encoding)},
		},
		cfg.supportErrorEvents,
		cfg.recursive,
		cfg.credentialCookieKey,
	)
}