url

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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

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

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