summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/phpdaemon/init.go
blob: 0f05d01ee335f646ee87a9b63678ee53cbd4cd4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// SPDX-License-Identifier: GPL-3.0-or-later

package phpdaemon

import (
	"errors"

	"github.com/netdata/netdata/go/go.d.plugin/pkg/web"
)

func (p *PHPDaemon) validateConfig() error {
	if p.URL == "" {
		return errors.New("url not set")
	}
	if _, err := web.NewHTTPRequest(p.Request); err != nil {
		return err
	}
	return nil
}

func (p *PHPDaemon) initClient() (*client, error) {
	httpClient, err := web.NewHTTPClient(p.Client)
	if err != nil {
		return nil, err
	}
	return newAPIClient(httpClient, p.Request), nil
}