url

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package url provides url fuctionalities to provide consistent parsing for Kwil clients.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownScheme = errors.New("unknown scheme")
)

Functions

func HasScheme added in v0.2.0

func HasScheme(u string) (bool, error)

hasScheme returns true if the url has a known scheme.

Types

type Scheme

type Scheme string

Scheme is a protocol scheme, such as http or tcp.

const (
	HTTP  Scheme = "http"
	HTTPS Scheme = "https"
	TCP   Scheme = "tcp"
	UNIX  Scheme = "unix"
)

func (Scheme) String

func (s Scheme) String() string

func (Scheme) Valid added in v0.2.0

func (s Scheme) Valid() bool

type URL

type URL struct {
	// Original is the original URL string.
	Original string
	// Scheme is the protocol scheme, such as http or tcp.
	Scheme Scheme
	// Target is either the host, host:port, or unix socket path.
	Target string
	// Port is the port number, or 0 if not specified.
	Port int
	// contains filtered or unexported fields
}

URL is a parsed URL.

func ParseURL

func ParseURL(u string) (*URL, error)

ParseURL parses a URL string into a URL struct. URLs can be of the form: - http://localhost:8080 - tcp://localhost:8080 - localhost:8080 - localhost - unix:///var/run/kwil.sock If the URL does not have a scheme, it is assumed to be a tcp address. If it does not have a port, it is set to 0. This is only appropriate for listen addresses.

func ParseURLWithDefaultScheme added in v0.2.0

func ParseURLWithDefaultScheme(u, defaultScheme string) (*URL, error)

ParseURLWithDefaultScheme is like ParseURL, but the default scheme may be specified. If empty, "tcp://" is used.

func (*URL) URL added in v0.2.0

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

URL returns the parsed url.URL.

Jump to

Keyboard shortcuts

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