toolpageorg

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package toolpageorg provides an interface to the en.toolpage.org web service.

Index

Examples

Constants

This section is empty.

Variables

View Source
var IOReadAll = io.ReadAll

IOReadAll is a copy of io.ReadAll function to ease mock it's behavior during test.

View Source
var LogInfo = info.Log

LogInfo is a copy of info.Log function to ease mock it's behavior during test.

NewDocument is a copy of goquery.NewDocumentFromReader function to ease mock it's behavior during test.

Functions

This section is empty.

Types

type Client

type Client struct {
	EndpointURL string
}

Client holds information to request en.toolpage.org's URL.

func New

func New() *Client

New returns a new Client for the en.toolpage.org API with default values.

func (*Client) GetIP

func (c *Client) GetIP() (net.IP, error)

GetIP returns the current IP address detected by en.toolpage.org.

func (*Client) Name

func (c *Client) Name() string

Name returns the URL of the current provider as its name.

Example
package main

import (
	"fmt"

	"github.com/KEINOS/whereami/pkg/provider/providers/toolpageorg"
)

func main() {
	cli := toolpageorg.New()

	fmt.Println(cli.Name())

}
Output:

https://en.toolpage.org/tool/ip-address

func (*Client) SetURL

func (c *Client) SetURL(url string)

SetURL overrides the default value of the API endpoint URL.

type Response

type Response struct {
	Provider   string `json:"provider"`
	IP         string `json:"ip"`
	Hostname   string `json:"hostname,omitempty"`
	IPVersion  string `json:"ipVersion,omitempty"`
	RemotePort string `json:"remotePort,omitempty"`
}

Response is the structure of JSON from the API response of en.toolpage.org.

func GetResponse

func GetResponse(urlProvider string) (*Response, error)

GetResponse returns the Response object parsed from the en.toolpage.org's content body.

func (*Response) String

func (r *Response) String() string

String returns the struct pretty in JSON format.

Jump to

Keyboard shortcuts

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