url

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package url provides URL value helpers exposed to WebGo programs.

Index

Constants

View Source
const MaxEncodedSize = 8 * 1024

MaxEncodedSize bounds both accepted query text and serialized output.

Variables

View Source
var (
	// ErrInvalidQuery reports malformed percent-encoding or invalid UTF-8.
	ErrInvalidQuery = errors.New("invalid URL query")
	// ErrQueryTooLarge reports a query that exceeds MaxEncodedSize.
	ErrQueryTooLarge = errors.New("URL query exceeds size limit")
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key   string
	Value string
}

Entry is one ordered URLSearchParams name/value pair.

type URLSearchParams

type URLSearchParams struct {
	// contains filtered or unexported fields
}

URLSearchParams stores ordered query name/value pairs, including duplicate names and empty values.

func New

func New() *URLSearchParams

New creates an empty URLSearchParams value.

func Parse

func Parse(raw string) (*URLSearchParams, error)

Parse decodes an application/x-www-form-urlencoded query string.

func (*URLSearchParams) Append

func (params *URLSearchParams) Append(key, value string) error

Append adds one value without removing existing values for key.

func (*URLSearchParams) Delete

func (params *URLSearchParams) Delete(key string)

Delete removes every value for key.

func (*URLSearchParams) Encode

func (params *URLSearchParams) Encode() (string, error)

Encode serializes params as application/x-www-form-urlencoded text.

func (*URLSearchParams) Entries

func (params *URLSearchParams) Entries() []Entry

Entries returns a defensive copy in insertion order.

func (*URLSearchParams) Get

func (params *URLSearchParams) Get(key string) (string, bool)

Get returns the first value for key.

func (*URLSearchParams) GetAll

func (params *URLSearchParams) GetAll(key string) []string

GetAll returns all values for key in insertion order.

func (*URLSearchParams) Has

func (params *URLSearchParams) Has(key string) bool

Has reports whether key has at least one value.

func (*URLSearchParams) Set

func (params *URLSearchParams) Set(key, value string) error

Set replaces all values for key while retaining the first matching position.

Jump to

Keyboard shortcuts

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