Documentation ¶
Overview ¶
Package metadata contains metadata storage used across buypal application.
Package metadata contains a metadata store used across multiple services. It is used to pass the headers from the request to other services.
Index ¶
- Constants
- func AcceptLanguage(ctx context.Context) (language.Tag, bool)
- func AcceptLanguages(ctx context.Context) ([]language.Tag, bool)
- func ContentLanguage(ctx context.Context) (language.Tag, bool)
- func Get(ctx context.Context, key string) (string, bool)
- func MergeContext(ctx context.Context, patchMd Meta, overwrite bool) context.Context
- func NewContext(ctx context.Context, md Meta) context.Context
- func RemoteIP(ctx context.Context) (string, bool)
- func RequestID(ctx context.Context) (string, bool)
- func Token(ctx context.Context) (string, bool)
- func UserID(ctx context.Context) (string, bool)
- type Meta
- func (m Meta) AcceptLanguage() (language.Tag, bool)
- func (m Meta) AcceptLanguages() ([]language.Tag, bool)
- func (m Meta) ContentEncoding() (string, bool)
- func (m Meta) ContentLanguage() (language.Tag, bool)
- func (m Meta) Currency() (currency.Unit, bool)
- func (m Meta) Delete(key string)
- func (m Meta) Get(key string) (string, bool)
- func (m Meta) RemoteIP() (string, bool)
- func (m Meta) RequestID() (string, bool)
- func (m Meta) Set(key, value string)
- func (m Meta) SetAcceptLanguages(tags []language.Tag)
- func (m Meta) SetContentEncoding(encoding string)
- func (m Meta) SetContentLanguage(tag language.Tag)
- func (m Meta) SetCurrency(c currency.Unit)
- func (m Meta) SetRemoteIP(remoteIP string)
- func (m Meta) SetRequestID(requestID string)
- func (m Meta) SetToken(token string)
- func (m Meta) SetUserID(userID string)
- func (m Meta) Token() (string, bool)
- func (m Meta) UserID() (string, bool)
Constants ¶
const ( KeyContentLanguage = "contentLanguage" KeyAcceptLanguages = "acceptLanguage" KeyCurrency = "currency" KeyUserID = "userId" KeyToken = "token" KeyContentEncoding = "contentEncoding" KeyRemoteIP = "remoteIp" KeyRequestID = "requestId" )
Constant metadata key definitions.
Variables ¶
This section is empty.
Functions ¶
func AcceptLanguage ¶
AcceptLanguage gets the first accepted language stored in the context metadata.
func AcceptLanguages ¶
AcceptLanguages gets the accepted languages stored in the context metadata.
func ContentLanguage ¶
ContentLanguage gets the content language from the context metadata.
func MergeContext ¶
MergeContext merges metadata to existing metadata, overwriting if specified
func NewContext ¶
NewContext creates a new context with the given metadata
Types ¶
type Meta ¶
Meta is the metadata container used in the flow of applications.
func FromContext ¶
FromContext gets the metadata from the context.
func MustFromContext ¶
MustFromContext gets the metadata from the context.
func (Meta) AcceptLanguage ¶
AcceptLanguage gets accepted language with the highest quality.
func (Meta) AcceptLanguages ¶
AcceptLanguages gets accepted languages by the user stored by the quality.
func (Meta) ContentEncoding ¶
ContentEncoding sets the content encoding.
func (Meta) ContentLanguage ¶
ContentLanguage gets the content language from the metadata.
func (Meta) SetAcceptLanguages ¶
SetAcceptLanguages sets up request accepted languages by the user with the quality order.
func (Meta) SetContentEncoding ¶
SetContentEncoding sets the content encoding.
func (Meta) SetContentLanguage ¶
SetContentLanguage sets up language metadata.
func (Meta) SetCurrency ¶
SetCurrency sets up currency metadata.
func (Meta) SetRemoteIP ¶
SetRemoteIP sets the remoteIP in the metadata.
func (Meta) SetRequestID ¶
SetRequestID sets the request id in the metadata.