net

package
v3.35.0 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAddress = errors.New("invalid address")
	ErrInvalidSchema  = errors.New("invalid schema")
)

Functions

This section is empty.

Types

type URI

type URI struct {
	Scheme string `json:"scheme"`
	Host   string `json:"host"`
	Port   uint16 `json:"port"`
}

URI represents a Pilosa URI. A Pilosa URI consists of three parts: 1) Scheme: Protocol of the URI. Default: http. 2) Host: Hostname or IP URI. Default: localhost. IPv6 addresses should be written in brackets, e.g., `[fd42:4201:f86b:7e09:216:3eff:fefa:ed80]`. 3) Port: Port of the URI. Default: 10101.

All parts of the URI are optional. The following are equivalent:

http://localhost:10101
http://localhost
http://:10101
localhost:10101
localhost
:10101

func DefaultURI

func DefaultURI() *URI

DefaultURI creates and returns the default URI.

func NewURIFromAddress

func NewURIFromAddress(address string) (*URI, error)

NewURIFromAddress parses the passed address and returns a URI.

func NewURIFromHostPort

func NewURIFromHostPort(host string, port uint16) (*URI, error)

NewURIFromHostPort returns a URI with specified host and port.

func (URI) Equals

func (u URI) Equals(other *URI) bool

Equals returns true if the checked URI is equivalent to this URI.

func (*URI) HostPort

func (u *URI) HostPort() string

HostPort returns `Host:Port`

func (*URI) MarshalJSON

func (u *URI) MarshalJSON() ([]byte, error)

MarshalJSON marshals URI into a JSON-encoded byte slice.

func (*URI) Normalize

func (u *URI) Normalize() string

normalize returns the address in a form usable by a HTTP client.

func (*URI) Path

func (u *URI) Path(path string) string

Path returns URI with path

func (*URI) Set

func (u *URI) Set(value string) error

Set sets the uri value.

func (*URI) SetHost

func (u *URI) SetHost(host string) error

SetHost sets the host of this URI.

func (*URI) SetPort

func (u *URI) SetPort(port uint16)

SetPort sets the port of this URI.

func (*URI) SetScheme

func (u *URI) SetScheme(scheme string) error

SetScheme sets the scheme of this URI.

func (URI) String

func (u URI) String() string

String returns the address as a string.

func (URI) Translate

func (u URI) Translate(nat map[URI]URI) URI

Translate returns the translated URI based on the provided NAT map.

func (URI) Type

func (u URI) Type() string

Type returns the type of a uri.

func (*URI) URL

func (u *URI) URL() url.URL

URL returns a url.URL representation of the URI.

func (*URI) UnmarshalJSON

func (u *URI) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a byte slice to a URI.

type URIs

type URIs []URI

URIs is a convenience type representing a slice of URI.

func (URIs) HostPortStrings

func (u URIs) HostPortStrings() []string

HostPortStrings returns a slice of host:port strings based on the slice of URI.

Jump to

Keyboard shortcuts

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