pdnshttp

package
v0.0.0-...-cb3ac65 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound ...

Types

type ErrNotFound

type ErrNotFound struct {
	URL string
}

ErrNotFound error not found with URL

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type ErrUnexpectedStatus

type ErrUnexpectedStatus struct {
	URL        string
	StatusCode int
}

ErrUnexpectedStatus error with URL and HTTP status code

func (ErrUnexpectedStatus) Error

func (e ErrUnexpectedStatus) Error() string

type PDNSClient

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

PDNSClient is the client for PowerDNS API

func NewPDNSClient

func NewPDNSClient(baseURL string, hc *http.Client, debugOutput io.Writer) *PDNSClient

NewPDNSClient creates a new PDNSClient

func (*PDNSClient) Delete

func (pc *PDNSClient) Delete(path string, out interface{}, opts ...RequestOption) error

Delete executes a DELETE request

func (*PDNSClient) Get

func (pc *PDNSClient) Get(path string, out interface{}, opts ...RequestOption) error

Get executes a GET request

func (*PDNSClient) NewRequest

func (pc *PDNSClient) 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 (*PDNSClient) Patch

func (pc *PDNSClient) Patch(path string, out interface{}, opts ...RequestOption) error

Patch executes a PATCH request

func (*PDNSClient) Post

func (pc *PDNSClient) Post(path string, out interface{}, opts ...RequestOption) error

Post executes a POST request

func (*PDNSClient) Put

func (pc *PDNSClient) Put(path string, out interface{}, opts ...RequestOption) error

Put executes a PUT request

type RequestOption

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

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

func WithQueryValue(key, value string) RequestOption

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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