req

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(r *http.Request) url.Values

All returns all request variables as a url.Values object

Parameters:

  • r *http.Request: HTTP request

Returns:

  • url.Values: all request variables

func Array

func Array(r *http.Request, key string, defaultValue []string) []string

Array returns an array from the request

Parameters:

  • r *http.Request: HTTP request
  • key string: key to get array for
  • defaultValue []string: default value to return if key does not exist

Returns:

  • []string: array for key, or default value if not exists

func Has

func Has(r *http.Request, key string) bool

Has returns true if GET or POST key exists

Parameters:

  • r *http.Request: HTTP request
  • key string: key to check if exists

Returns:

  • bool: true if key exists

func HasGet

func HasGet(r *http.Request, key string) bool

HasGet returns true if GET key exists

Parameters:

  • r *http.Request: HTTP request
  • key string: key to check if exists

Returns:

  • bool: true if key exists

func HasPost

func HasPost(r *http.Request, key string) bool

HasPost returns true if POST key exists

Parameters:

  • r *http.Request: HTTP request
  • key string: key to check if exists

Returns:

  • bool: true if key exists

func IP added in v0.15.0

func IP(r *http.Request) string

IP gets the IP address for the user

func Map

func Map(r *http.Request, key string) map[string]string

Map returns a map from the request

Parameters:

  • r *http.Request: HTTP request
  • key string: key to get map for

Returns:

  • map[string]string: map for key

func Maps

func Maps(r *http.Request, key string, defaultValue []map[string]string) []map[string]string

func Subdomain added in v0.0.3

func Subdomain(r *http.Request) (string, error)

Subdomain finds the subdomain in the host of the given request.

Business logic: - extract the host from the request - if the host is "localhost", return an empty string - if there is no dot in the host, return an empty string - otherwise, return the part of the host before the first dot

Parameters:

  • r (*http.Request): The HTTP request from which to extract the subdomain.

Returns:

  • string: the subdomain, or an empty string if none found.
  • error: an error if any, otherwise nil.

func TrimmedValue added in v0.16.0

func TrimmedValue(r *http.Request, key string) string

TrimmedValue returns a POST or GET key, trimmed, or empty string if not exists

Parameters:

  • r *http.Request: HTTP request
  • key string: key to get value for

Returns:

  • string: trimmed value for key, or empty string if not exists

func TrimmedValueOr added in v0.16.0

func TrimmedValueOr(r *http.Request, key string, defaultValue string) string

TrimmedValueOr returns a POST or GET key, trimmed, or provided default value if not exists or if the found value is empty after trimming. The default value is also trimmed.

Parameters:

  • r *http.Request: HTTP request
  • key string: key to get value for
  • defaultValue string: default value to return if key does not exist or value is empty after trimming

Returns:

  • string: trimmed value for key, or trimmed default value if appropriate

func Value

func Value(r *http.Request, key string) string

Value returns a POST or GET key, or empty string if not exists

Parameters:

  • r *http.Request: HTTP request
  • key string: key to get value for

Returns:

  • string: value for key, or empty string if not exists

func ValueOr

func ValueOr(r *http.Request, key string, defaultValue string) string

ValueOr returns a POST or GET key, or provided default value if not exists

Parameters:

  • r *http.Request: HTTP request
  • key string: key to get value for
  • defaultValue string: default value to return if key does not exist

Returns:

  • string: value for key, or default value if not exists

Types

This section is empty.

Jump to

Keyboard shortcuts

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