Exemplo n.º 1
0
func newConsulDriver(opts util.DynamicMap) (Driver, error) {
	u, err := url.Parse(
		opts.Get("URL", "http://localhost:8500").(string))
	if err != nil {
		return nil, err
	}

	return &consulDisco{
		client: http.Client{Timeout: 5 * time.Second},
		consul: u,
	}, nil
}
Exemplo n.º 2
0
func newGETDriver(host string, port uint16, opts util.DynamicMap) (Driver, error) {
	c := http.Client{Timeout: 5 * time.Second, CheckRedirect: func(
		req *http.Request,
		via []*http.Request,
	) error {
		return errRedirects
	}}

	u := url.URL{
		Scheme: "http",
		Host:   fmt.Sprintf("%s:%d", host, port),
		Path:   opts.Get("path", "/").(string)}

	r, err := http.NewRequest(opts.Get("method", "GET").(string), u.String(), nil)
	if err != nil {
		return nil, err
	}

	return &httpPulse{
		client: c,
		httpRq: r,
		expect: opts.Get("expect", 200).(int),
	}, nil
}