api

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

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

Go to latest
Published: Oct 21, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package api loads configuration data from api.fast.com.

Index

Constants

View Source
const (
	// DefaultToken is a known api.fast.com token, used by Load if no other token
	// is specified.
	DefaultToken = "YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm"
	// DefaultUserAgent is used by Load if no other user agent is specified.
	DefaultUserAgent = "fast/0.1 (" + runtime.GOOS + "; " + runtime.GOARCH + ")"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// ASN is the ISP's Autonomous System Number.
	//
	// For example, CenturyLink's ASN is 209.
	// https://whois.arin.net/rest/asn/AS209
	ASN string `json:"asn"`
	// ISP is the name of the ISP.
	ISP      string   `json:"isp"`
	Location Location `json:"location"`
	// IP is the client's public IP address.
	IP net.IP `json:"ip"`
}

Client contains information on the client requesting the configuration.

type Config

type Config struct {
	// Client contains information on the client requesting the configuration.
	Client Client `json:"client"`
	// Targets contains
	Targets []Target `json:"targets"`
}

Config is an api.fast.com configuration.

func Load

func Load(opts ...Option) (*Config, error)

Load fetches api.fast.com's configuration.

type Location

type Location struct {
	Country string `json:"country"`
	City    string `json:"city"`
}

type Option

type Option func(*loader)

Option is a function that modifies the loading of an API configuration.

func NumURLs

func NumURLs(n int) Option

NumURLs sets the number of URLs the configuration should contain.

func WithClient

func WithClient(hc *http.Client) Option

WithClient sets the Client used to load the configuration.

func WithToken

func WithToken(token string) Option

WithToken sets the API token used to load the configuration.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent sets the user agent to use while loading the configuration.

type Target

type Target struct {
	// URL is file's URL.
	URL string `json:"url"`
	// Location currently contains (Netflix, Open Connect).
	Location Location `json:"location"`
	// Name is currently set to the same thing as URL.
	Name string `json:"name"`
}

Target describes a particular file used to measure download speed.

Jump to

Keyboard shortcuts

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