Documentation ¶
Overview ¶
Package headers package provides header name constants and get/set functions for commonly used http headers in the dp-api-clients-go repo. Package replaces go-ns lib and should be treated as the single source of truth
Index ¶
- Constants
- Variables
- func GetCollectionID(req *http.Request) (string, error)
- func GetDownloadServiceToken(req *http.Request) (string, error)
- func GetETag(req *http.Request) (string, error)
- func GetIfMatch(req *http.Request) (string, error)
- func GetLocaleCode(req *http.Request) (string, error)
- func GetRequestID(req *http.Request) (string, error)
- func GetResponseETag(resp *http.Response) (string, error)
- func GetServiceAuthToken(req *http.Request) (string, error)
- func GetUserAuthToken(req *http.Request) (string, error)
- func GetUserIdentity(req *http.Request) (string, error)
- func IsErrNotFound(err error) bool
- func IsNotErrNotFound(err error) bool
- func SetAcceptedLang(req *http.Request, headerValue string) error
- func SetAuthToken(req *http.Request, headerValue string) error
- func SetCollectionID(req *http.Request, headerValue string) error
- func SetDownloadServiceToken(req *http.Request, headerValue string) error
- func SetETag(req *http.Request, headerValue string) error
- func SetIDTokenHeader(req *http.Request, headerValue string) error
- func SetIfMatch(req *http.Request, headerValue string) error
- func SetLocaleCode(req *http.Request, headerValue string) error
- func SetRefreshTokenHeader(req *http.Request, headerValue string) error
- func SetRequestID(req *http.Request, headerValue string) error
- func SetServiceAuthToken(req *http.Request, headerValue string) error
- func SetUserIdentity(req *http.Request, headerValue string) error
Constants ¶
const (
// IfMatchAnyETag is a wildchar value for If-Match header to ask the API to ignore the ETag check
IfMatchAnyETag = "*"
)
Variables ¶
var ( // ErrHeaderNotFound returned if the requested header is not present in the provided request ErrHeaderNotFound = errors.New("header not found") // ErrValueEmpty returned if an empty value is passed when a non-empty value is required ErrValueEmpty = errors.New("header not set as value was empty") // ErrRequestNil return if SetX header function is called with a nil request ErrRequestNil = errors.New("error setting request header request was nil") // ErrResponseNil return if GetResponseX header function is called with a nil response ErrResponseNil = errors.New("error getting request header, response was nil") )
Functions ¶
func GetCollectionID ¶
GetCollectionID returns the value of the "Collection-Id" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetDownloadServiceToken ¶
GetDownloadServiceToken returns the value of the "X-Download-Service-Token" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetETag ¶
GetETag returns the value of the "ETag" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetIfMatch ¶
GetIfMatch returns the value of the "If-Match" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetLocaleCode ¶
GetLocaleCode returns the value of the "LocaleCode" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetRequestID ¶
GetRequestID returns the value of the "X-Request-Id" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetResponseETag ¶
GetResponseETag returns the value of "ETag" response header if it exists, returns ErrResponseNil if the header is not found.
func GetServiceAuthToken ¶
GetServiceAuthToken returns the value of the "Authorization" request header if it exists, returns ErrHeaderNotFound if the header is not found. If the header exists the "Bearer " prefixed is removed from returned value.
func GetUserAuthToken ¶
GetUserAuthToken returns the value of the "X-Florence-Token" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func GetUserIdentity ¶
GetUserIdentity returns the value of the "User-Identity" request header if it exists, returns ErrHeaderNotFound if the header is not found.
func IsErrNotFound ¶
IsErrNotFound return true if the err equal to ErrHeaderNotFound. Return false otherwise
func IsNotErrNotFound ¶
IsNotErrNotFound return true if error is not nil and not equal to ErrHeaderNotFound
func SetAcceptedLang ¶ added in v2.7.1
func SetAuthToken ¶
SetAuthToken set the access token header on the provided request. If the access token is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetCollectionID ¶
SetCollectionID set the collection ID header on the provided request. If the collection ID header is already present in the request it will be overwritten by the new value. Empty values are allowed for this header
func SetDownloadServiceToken ¶
SetDownloadServiceToken set the download service auth token header on the provided request. If the authentication token is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetETag ¶
SetETag set the ETag header on the provided request. If this header is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetIDTokenHeader ¶ added in v2.1.11
SetIDTokenHeader set the ID token header on the provided request. If the authentication token is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetIfMatch ¶
SetIfMatch set the If-Match header on the provided request. If this header is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetLocaleCode ¶
SetLocaleCode set the locale code header on the provided request. If this header is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetRefreshTokenHeader ¶ added in v2.1.11
SetRefreshTokenHeader set the refresh token header on the provided request. If the authentication token is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetRequestID ¶
SetRequestID set the unique request ID header on the provided request. If a request ID header is already present it will be overwritten by the new value. Empty values are allowed for this header.
func SetServiceAuthToken ¶
SetServiceAuthToken set the service authentication token header on the provided request. If the authentication token is already present it will be overwritten by the new value. Empty values are allowed for this header. Replaces deprecated SetUserAuthToken function.
Types ¶
This section is empty.