cookies

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 7 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCollection

func GetCollection(req *http.Request) (string, error)

GetCollection reads collection_id cookie and returns it's value

func GetIDToken added in v0.2.0

func GetIDToken(req *http.Request) (string, error)

GetIDToken reads id_token cookie and returns it's value

func GetLang

func GetLang(req *http.Request) (string, error)

GetLang reads lang cookie and returns it's value

func GetRefreshToken added in v0.2.0

func GetRefreshToken(req *http.Request) (string, error)

GetRefreshToken reads refresh_token cookie and returns it's value

func GetUserAuthToken

func GetUserAuthToken(req *http.Request) (string, error)

GetUserAuthToken reads access_token cookie and returns it's value

func SetABTest added in v0.3.0

func SetABTest(w http.ResponseWriter, servs ABServices, domain string) error

SetABTest sets a cookie containing collection ID

func SetCollection

func SetCollection(w http.ResponseWriter, value, domain string)

SetCollection sets a cookie containing collection ID

func SetIDToken added in v0.2.0

func SetIDToken(w http.ResponseWriter, idToken, domain string)

SetIDToken sets a cookie containing users id token ("id_token")

func SetLang

func SetLang(w http.ResponseWriter, lang, domain string)

SetLang sets a cookie containing locale code

func SetPolicy

func SetPolicy(w http.ResponseWriter, policy Policy, domain string)

SetPolicy sets a cookie with the users preferences, or sets default preferences on error

func SetPreferenceIsSet

func SetPreferenceIsSet(w http.ResponseWriter, domain string)

SetPreferenceIsSet sets a cookie to record a user has set cookie preferences

func SetRefreshToken added in v0.2.0

func SetRefreshToken(w http.ResponseWriter, refreshToken, domain string)

SetRefreshToken sets a cookie containing users refresh token ("refresh_token")

func SetUserAuthToken

func SetUserAuthToken(w http.ResponseWriter, userAuthToken, domain string)

SetUserAuthToken sets a cookie containing users auth token ("access token")

func UpdateNewSearch added in v0.3.0

func UpdateNewSearch(req *http.Request, w http.ResponseWriter, newValue time.Time, domain string) error

UpdateNewSearch updates new search value in A/B test cookie

func UpdateOldSearch added in v0.3.0

func UpdateOldSearch(req *http.Request, w http.ResponseWriter, newValue time.Time, domain string) error

UpdateOldSearch updates old search value in A/B test cookie

Types

type ABServices added in v0.3.0

type ABServices struct {
	NewSearch *time.Time `json:"new_search,omitempty"`
	OldSearch *time.Time `json:"old_search,omitempty"`
}

ABServices contains all services in A/B test and their expiry date

func GetABTest added in v0.3.0

func GetABTest(req *http.Request) (ABServices, error)

GetABTest reads ab_test cookie and returns it's value

type Policy

type Policy struct {
	Essential bool `json:"essential"`
	Usage     bool `json:"usage"`
}

Policy is cookie policy setting choosen by a user

type PreferencesResponse

type PreferencesResponse struct {
	IsPreferenceSet bool
	Policy          Policy
}

PreferencesResponse is a combination of cookie policy and whether they have be set by user

func GetCookiePreferences

func GetCookiePreferences(req *http.Request) PreferencesResponse

GetCookiePreferences returns a struct with all cookie preferences

Jump to

Keyboard shortcuts

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