params

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: CC0-1.0, BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package params is a MediaWiki specific replacement for parts of net/url. Specifically, it contains a fork of url.Values (params.Values) that is based on map[string]string instead of map[string][]string. The purpose of this is that the MediaWiki API does not use multiple keys to allow multiple values for a key (e.g., "a=b&a=c"). Instead it uses one key with values separated by a pipe (e.g. "a=b|c").

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Values

type Values map[string]string

Values maps a string key to a string value. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive.

func (Values) Add

func (v Values) Add(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Values) AddRange

func (v Values) AddRange(key string, values ...string)

AddRange adds multiple values to a key. It appends to any existing values associated with key.

func (Values) Del

func (v Values) Del(key string)

Del deletes the value associated with key.

func (Values) Encode

func (v Values) Encode() string

Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key. Encode is a slightly modified version of Values.Encode() from net/url. It encodes url.Values into URL encoded form, sorted by key, with the exception of the key "token", which will be appended to the end instead of being subject to regular sorting. This is done in accordance with MW API guidelines to ensure that an action will not be executed if the query string has been cut off for some reason.

func (Values) EncodeMultipart added in v1.2.0

func (v Values) EncodeMultipart() (data string, contentType string, err error)

EncodeMultipart returns a “multipart encoded” version of the parameters as a string, along with a Content-Type header string to use, and an error if something somehow goes dramatically wrong.

func (Values) Get

func (v Values) Get(key string) string

Get gets the value associated with the given key. If there are no values associated with the key, Get returns the empty string.

func (Values) Set

func (v Values) Set(key, value string)

Set sets the key to value. It replaces any existing values.

Jump to

Keyboard shortcuts

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