request

package
v0.0.0-...-648fd64 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

//////////////////////////////////////////////////////////////////// request.go ////////////////////////////////////////////////////////////////////

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLangCode

func GetLangCode(r *http.Request, supportedLangCodes []string, defaultLangCode, urlQueryKey, cookieName string) string

//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits. Resolve a language code in the following priority order:

  1. URL parameter (such as "lang=en")
  2. Cookie (such as "lang")
  3. HTTP Header ("Accept-Language")

When it could not resolve a language code, will be returned defaultLangCode such as "en". ////////////////////////////////////////////////////////////////////

func GetLangCodeFromAcceptLanguage

func GetLangCodeFromAcceptLanguage(r *http.Request) string

//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits from HTTP Header ("Accept-Language"). ////////////////////////////////////////////////////////////////////

func GetLangCodeFromCookie

func GetLangCodeFromCookie(r *http.Request, supportedLangCodes []string, cookieName string) string

//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits from cookie. ////////////////////////////////////////////////////////////////////

func GetLangCodeFromUrlQuery

func GetLangCodeFromUrlQuery(r *http.Request, supportedLangCodes []string, urlQueryKey string) string

//////////////////////////////////////////////////////////////////// Get the lang code with 2 digits from URL query. ////////////////////////////////////////////////////////////////////

Types

This section is empty.

Jump to

Keyboard shortcuts

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