summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/lighttpd/init.go
blob: c0dae5e7b64fadfa7fe24c82debf7d39d10b4104 (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
28
29
// SPDX-License-Identifier: GPL-3.0-or-later

package lighttpd

import (
	"errors"
	"fmt"
	"strings"

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

func (l *Lighttpd) validateConfig() error {
	if l.URL == "" {
		return errors.New("url not set")
	}
	if !strings.HasSuffix(l.URL, "?auto") {
		return fmt.Errorf("bad URL '%s', should ends in '?auto'", l.URL)
	}
	return nil
}

func (l *Lighttpd) initApiClient() (*apiClient, error) {
	client, err := web.NewHTTPClient(l.Client)
	if err != nil {
		return nil, err
	}
	return newAPIClient(client, l.Request), nil
}