fritzclient

package
v0.0.0-...-7c6a5d1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fritzclient contains an HTTP client to access the fritz box.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an HTTP client to access the FRITZ!Box.

func New

func New(addr, user, pass string, opts ...OptFunc) (*Client, error)

New returns a new FRITZ! HTTP client.

func (*Client) Info

func (c *Client) Info(ctx context.Context) (fritztypes.Info, error)

Info returns fritz basic information.

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context) ([]fritztypes.User, error)

ListUsers returns fritz users.

type HTTPError

type HTTPError struct {
	Status int
	URL    string
}

HTTPError represents an undesired HTTP response.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type OptFunc

type OptFunc func(*Client)

OptFunc applies optional client configuration.

func WithURLBuilder

func WithURLBuilder(ub URLBuilder) OptFunc

WithURLBuilder applies a custom URL builder.

The main purpose is testing.

type URLBuilder

type URLBuilder interface {
	WithPort(uint16) URLBuilder
	WithPath(string) URLBuilder
	WithQuery(string, string) URLBuilder
	String() string
}

URLBuilder represents a URL builder with a fluent interface.

type URLBuilderImpl

type URLBuilderImpl struct {
	URL *url.URL
}

URLBuilderImpl builds URLs in a fluent interface style.

func (*URLBuilderImpl) String

func (u *URLBuilderImpl) String() string

String returns the URL as a string.

func (*URLBuilderImpl) WithPath

func (u *URLBuilderImpl) WithPath(path string) URLBuilder

WithPath applies the path.

func (*URLBuilderImpl) WithPort

func (u *URLBuilderImpl) WithPort(port uint16) URLBuilder

WithPort applies the port.

func (*URLBuilderImpl) WithQuery

func (u *URLBuilderImpl) WithQuery(key, value string) URLBuilder

WithQuery applies a query key-value pair.

Directories

Path Synopsis
Package middleware contains routing middleware.
Package middleware contains routing middleware.

Jump to

Keyboard shortcuts

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