ipify

package
v1.100.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package ipify allows to retrieve the public IP address of a service instance using the external ipify API (https://www.ipify.org/).

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 represents the config options required by this client.

func New

func New(opts ...Option) (*Client, error)

New creates a new ipify client instance.

func (*Client) GetPublicIP

func (c *Client) GetPublicIP(ctx context.Context) (string, error)

GetPublicIP retrieves the public IP of this service instance via ipify.com API.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient contains the function to perform the actual HTTP request.

type Option

type Option func(c *Client)

Option is the interface that allows to set client options.

func WithErrorIP

func WithErrorIP(s string) Option

WithErrorIP overrides the default error return string.

func WithHTTPClient

func WithHTTPClient(hc HTTPClient) Option

WithHTTPClient overrides the default HTTP client.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout overrides the default request timeout.

func WithURL

func WithURL(addr string) Option

WithURL overrides the default service URL.

Jump to

Keyboard shortcuts

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