queryparam

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package queryparam provides utilities for efficiently working with query parameters in URLs. It focuses on zero allocation URL query parameter lookups.

func handler(w http.ResponseWriter, r *http.Request) {
	// Get the value of the `key` query parameter.
	value := queryparam.Get(r.URL.RawQuery, "key")
}

Note that this method does not support multiple values for the same key, so using `val=1,2,3` is preferable to `val=1&val=2&val=3`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(query, name string) string

Get a query param by name without any dynamic allocations. For small numbers of query params, it is faster to call this method multiple times than to use `url.ParseQuery` and then call `Get` on the resulting `url.Values`. This method does not support multiple values for the same key, so using `val=1,2,3` is preferable to `val=1&val=2&val=3`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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