pdnshttp

package
v0.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type APIKeyAuthenticator

type APIKeyAuthenticator struct {
	APIKey string
}

func (*APIKeyAuthenticator) OnConnect

func (a *APIKeyAuthenticator) OnConnect(*http.Client) error

func (*APIKeyAuthenticator) OnRequest

func (a *APIKeyAuthenticator) OnRequest(r *http.Request) error

type BasicAuthenticator added in v0.6.0

type BasicAuthenticator struct {
	Username string
	Password string
}

func (*BasicAuthenticator) OnConnect added in v0.6.0

func (a *BasicAuthenticator) OnConnect(*http.Client) error

func (*BasicAuthenticator) OnRequest added in v0.6.0

func (a *BasicAuthenticator) OnRequest(r *http.Request) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string, hc *http.Client, auth ClientAuthenticator, debugOutput io.Writer) *Client

NewClient returns a new PowerDNS HTTP client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, out interface{}, opts ...RequestOption) error

Delete executes a DELETE request

func (*Client) Do added in v0.6.1

func (c *Client) Do(ctx context.Context, req *http.Request, out interface{}) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, out interface{}, opts ...RequestOption) error

Get executes a GET request

func (*Client) NewRequest

func (c *Client) NewRequest(method string, path string, body io.Reader) (*http.Request, error)

NewRequest builds a new request. Usually, this method should not be used; prefer using the "Get", "Post", ... methods if possible.

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, path string, out interface{}, opts ...RequestOption) error

Patch executes a PATCH request

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, out interface{}, opts ...RequestOption) error

Post executes a POST request

func (*Client) Put added in v0.2.0

func (c *Client) Put(ctx context.Context, path string, out interface{}, opts ...RequestOption) error

Put executes a PUT request

type ClientAuthenticator

type ClientAuthenticator interface {
	OnRequest(*http.Request) error
	OnConnect(*http.Client) error
}

type ErrNotFound

type ErrNotFound struct {
	URL string
}

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type ErrResponse added in v0.5.1

type ErrResponse struct {
	Message  string   `json:"error"`
	Messages []string `json:"errors,omitempty"`
}

ErrResponse represents error response from PowerDNS HTTP API

type ErrUnexpectedStatus

type ErrUnexpectedStatus struct {
	URL        string
	StatusCode int
	ErrResponse
}

func (ErrUnexpectedStatus) Error

func (e ErrUnexpectedStatus) Error() string

type NoopAuthenticator added in v0.2.2

type NoopAuthenticator struct{}

NoopAuthenticator provides an "empty" implementation of the ClientAuthenticator interface.

func (NoopAuthenticator) OnConnect added in v0.2.2

func (NoopAuthenticator) OnConnect(*http.Client) error

OnConnect is applied on the entire connection as soon as it is set up.

func (NoopAuthenticator) OnRequest added in v0.2.2

func (NoopAuthenticator) OnRequest(*http.Request) error

OnRequest is applied each time a HTTP request is built.

type RequestOption added in v0.2.0

type RequestOption func(*http.Request) error

RequestOption is a special type of function that can be passed to most HTTP request functions in this package; it is used to modify an HTTP request and to implement special request logic.

func WithJSONRequestBody added in v0.2.0

func WithJSONRequestBody(in interface{}) RequestOption

WithJSONRequestBody adds a JSON body to a request. The input type can be anything, as long as it can be marshaled by "json.Marshal". This method will also automatically set the correct content type and content-length.

func WithQueryValue added in v0.2.0

func WithQueryValue(key, value string) RequestOption

WithQueryValue adds a query parameter to a request's URL.

type TLSClientCertificateAuthenticator

type TLSClientCertificateAuthenticator struct {
	CACerts    []*x509.Certificate
	ClientCert tls.Certificate
	ClientKey  crypto.PrivateKey
}

func (*TLSClientCertificateAuthenticator) OnConnect

func (*TLSClientCertificateAuthenticator) OnRequest

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL