urls

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(p string) string

Return a file URL for the provided path

func Join

func Join(b string, c ...interface{}) string

Join a base URL together with path components, similar to the functionality of path.Join.

func MergeParams added in v1.31.0

func MergeParams(s string, p url.Values, opts ...MergeOption) (string, error)

Merge the specified queury parameters into the provided URL. This version accepts a set of options which control how the merge is performed. By default, parameters with existing keys are replaced, not added.

func MergeQuery

func MergeQuery(s string, p ...url.Values) (string, error)

Merge the specified queury parameters into the provided URL. Parameters with existing keys are added, not replaced. This function is depreacated and MergeParams() or MergeValues() should be preferred.

func MergeValues added in v1.31.0

func MergeValues(a, b url.Values, opts ...MergeOption) url.Values

Merge the specified values. Either one of the parameters or a new set of values is returned.

func ParseValueList

func ParseValueList(v []string, d string) []string

Parse parameters from the provided Values and produce a list of results for the specified key. Both values defined by repeatedly providing a key and those provided in a delimited list for a single key are returned.

For example, using the delimiter ',':

a=one&a=two        -> [one, two]
a=one,two          -> [one, two]
a=one,two&a=three  -> [one, two, three]

Use this method like so:

ParseValueList(vals["name"], ",")

Types

type MergeConfig added in v1.31.0

type MergeConfig struct {
	Append bool
}

func (MergeConfig) WithOptions added in v1.31.0

func (c MergeConfig) WithOptions(opts []MergeOption) MergeConfig

type MergeOption added in v1.31.0

type MergeOption func(MergeConfig) MergeConfig

func Append added in v1.31.0

func Append(b bool) MergeOption

Jump to

Keyboard shortcuts

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