Documentation
¶
Overview ¶
Package request contains functionality related to contexts and requests.
Index ¶
- Constants
- Variables
- func ContextAccountID(ctx context.Context) (string, error)
- func ContextHasScope(ctx context.Context, scope string) bool
- func ContextJWT(ctx context.Context) (string, error)
- func ContextNoCache(ctx context.Context) (bool, error)
- func ContextRemote(ctx context.Context) (string, error)
- func ContextReplaceTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc)
- func ContextRequestBody(ctx context.Context) (string, error)
- func ContextRequestURL(ctx context.Context) (*url.URL, error)
- func ContextScopes(ctx context.Context) (string, error)
- func ContextService(ctx context.Context) (string, error)
- func ContextTraceID(ctx context.Context) (string, error)
- func ContextUserID(ctx context.Context) (string, error)
- func SetField(doc *bson.D, name string, field any)
- func ValidAccountID(id string) bool
- func ValidAccountName(name string) bool
- func ValidGameID(id string) bool
- func ValidScope(scope string) bool
- func ValidScopes(scopes string) bool
- func ValidUserID(id string) bool
- type ContextKey
- type FieldBool
- func (f *FieldBool) MarshalBSON() ([]byte, error)
- func (f *FieldBool) MarshalJSON() ([]byte, error)
- func (f FieldBool) MarshalYAML() (any, error)
- func (f *FieldBool) Scan(src any) error
- func (f *FieldBool) String() string
- func (f *FieldBool) UnmarshalBSON(b []byte) error
- func (f *FieldBool) UnmarshalJSON(b []byte) error
- func (f *FieldBool) UnmarshalYAML(value *yaml.Node) error
- type FieldDuration
- func (f *FieldDuration) MarshalBSON() ([]byte, error)
- func (f *FieldDuration) MarshalJSON() ([]byte, error)
- func (f FieldDuration) MarshalYAML() (any, error)
- func (f *FieldDuration) Scan(src any) error
- func (f *FieldDuration) String() string
- func (f *FieldDuration) UnmarshalBSON(b []byte) error
- func (f *FieldDuration) UnmarshalJSON(b []byte) error
- func (f *FieldDuration) UnmarshalYAML(value *yaml.Node) error
- type FieldFloat64
- func (f *FieldFloat64) MarshalBSON() ([]byte, error)
- func (f *FieldFloat64) MarshalJSON() ([]byte, error)
- func (f FieldFloat64) MarshalYAML() (any, error)
- func (f *FieldFloat64) Scan(src any) error
- func (f *FieldFloat64) String() string
- func (f *FieldFloat64) UnmarshalBSON(b []byte) error
- func (f *FieldFloat64) UnmarshalJSON(b []byte) error
- func (f *FieldFloat64) UnmarshalYAML(value *yaml.Node) error
- type FieldInt64
- func (f *FieldInt64) MarshalBSON() ([]byte, error)
- func (f *FieldInt64) MarshalJSON() ([]byte, error)
- func (f FieldInt64) MarshalYAML() (any, error)
- func (f *FieldInt64) Scan(src any) error
- func (f *FieldInt64) String() string
- func (f *FieldInt64) UnmarshalBSON(b []byte) error
- func (f *FieldInt64) UnmarshalJSON(b []byte) error
- func (f *FieldInt64) UnmarshalYAML(value *yaml.Node) error
- type FieldInt64Array
- func (f *FieldInt64Array) MarshalBSON() ([]byte, error)
- func (f *FieldInt64Array) MarshalJSON() ([]byte, error)
- func (f FieldInt64Array) MarshalYAML() (any, error)
- func (f *FieldInt64Array) String() string
- func (f *FieldInt64Array) UnmarshalBSON(b []byte) error
- func (f *FieldInt64Array) UnmarshalJSON(b []byte) error
- func (f *FieldInt64Array) UnmarshalYAML(value *yaml.Node) error
- type FieldJSON
- func (f FieldJSON) Copy() FieldJSON
- func (f *FieldJSON) MarshalBSON() ([]byte, error)
- func (f *FieldJSON) MarshalJSON() ([]byte, error)
- func (f FieldJSON) MarshalYAML() (any, error)
- func (f *FieldJSON) Scan(src any) error
- func (f *FieldJSON) String() string
- func (f *FieldJSON) UnmarshalBSON(b []byte) error
- func (f *FieldJSON) UnmarshalJSON(b []byte) error
- func (f *FieldJSON) UnmarshalYAML(value *yaml.Node) error
- type FieldString
- func (f *FieldString) MarshalBSON() ([]byte, error)
- func (f *FieldString) MarshalJSON() ([]byte, error)
- func (f FieldString) MarshalYAML() (any, error)
- func (f *FieldString) Scan(src any) error
- func (f *FieldString) String() string
- func (f *FieldString) UnmarshalBSON(b []byte) error
- func (f *FieldString) UnmarshalJSON(b []byte) error
- func (f *FieldString) UnmarshalYAML(value *yaml.Node) error
- type FieldStringArray
- func (f *FieldStringArray) MarshalBSON() ([]byte, error)
- func (f *FieldStringArray) MarshalJSON() ([]byte, error)
- func (f FieldStringArray) MarshalYAML() (any, error)
- func (f *FieldStringArray) String() string
- func (f *FieldStringArray) UnmarshalBSON(b []byte) error
- func (f *FieldStringArray) UnmarshalJSON(b []byte) error
- func (f *FieldStringArray) UnmarshalYAML(value *yaml.Node) error
- type FieldTime
- func (f *FieldTime) MarshalBSON() ([]byte, error)
- func (f *FieldTime) MarshalJSON() ([]byte, error)
- func (f FieldTime) MarshalYAML() (any, error)
- func (f *FieldTime) Scan(src any) error
- func (f *FieldTime) String() string
- func (f *FieldTime) UnmarshalBSON(b []byte) error
- func (f *FieldTime) UnmarshalJSON(b []byte) error
- func (f *FieldTime) UnmarshalYAML(value *yaml.Node) error
- type Query
Constants ¶
const ( StatusActive = "active" StatusInactive = "inactive" StatusUpdating = "updating" StatusNew = "new" StatusError = "error" StatusPending = "pending" StatusCanceled = "canceled" StatusRemove = "remove" StatusRemoving = "removing" StatusModified = "modified" StatusBusy = "busy" StatusAlerting = "alerting" StatusRecovered = "recovered" StatusRunning = "running" StatusStopped = "stopped" StatusStopping = "stopping" StatusFailed = "failed" StatusSuccess = "success" StatusMaintenance = "maintenance" StatusActivating = "activating" StatusDeactivating = "deactivating" StatusDisconnected = "disconnected" StatusImporting = "importing" )
Valid status field values.
const ( DefaultAccount = "default" SystemAccount = "sys" SystemUser = "sys" )
Valid system entities.
const ( ScopeSuperuser = "superuser" ScopeAccountRead = "account:read" ScopeAccountWrite = "account:write" ScopeAccountAdmin = "account:admin" ScopeUserRead = "user:read" ScopeUserWrite = "user:write" ScopeUserAdmin = "user:admin" ScopeGamesRead = "games:read" ScopeGamesWrite = "games:write" ScopeGamesAdmin = "games:admin" )
Valid scopes.
Variables ¶
var Scopes = []string{ ScopeSuperuser, ScopeAccountRead, ScopeAccountWrite, ScopeAccountAdmin, ScopeUserRead, ScopeUserWrite, ScopeUserAdmin, ScopeGamesRead, ScopeGamesWrite, ScopeGamesAdmin, }
Scopes is a slice of all valid scopes.
Functions ¶
func ContextAccountID ¶
ContextAccountID extracts the account id from the context.
func ContextHasScope ¶
ContextHasScope tests whether the context contains a specified authorization scope.
func ContextJWT ¶
ContextJWT extracts the authentication token from the context.
func ContextNoCache ¶
ContextNoCache extracts the no cache flag from the context.
func ContextRemote ¶
ContextRemote extracts the remote address from the context.
func ContextReplaceTimeout ¶
func ContextReplaceTimeout(ctx context.Context, d time.Duration, ) (context.Context, context.CancelFunc)
ContextReplaceTimeout creates a copy of an existing context but with a new timeout.
func ContextRequestBody ¶
ContextRequestBody retrieves the current request body from the context.
func ContextRequestURL ¶
ContextRequestURL retrieves the current request URL from the context.
func ContextScopes ¶
ContextScopes extracts the authorization scopes from the context.
func ContextService ¶
ContextService extracts the service name from the context.
func ContextTraceID ¶
ContextTraceID extracts the trace id from the context.
func ContextUserID ¶
ContextUserID extracts the user id from the context.
func ValidAccountID ¶
ValidAccountID checks whether a string is a valid account ID.
func ValidAccountName ¶
ValidAccountName checks whether a string is a valid account name.
func ValidGameID ¶
ValidGameID checks whether a string is a valid external game ID.
func ValidScope ¶
ValidScope checks whether a string is a valid scope.
func ValidScopes ¶
ValidScopes checks whether a string is a valid scope.
func ValidUserID ¶
ValidUserID checks whether a string is a valid user ID.
Types ¶
type ContextKey ¶
type ContextKey int
ContextKey values are used to index context data.
const ( // CtxKeyService is used to select the service name from a context. CtxKeyService ContextKey = iota // CtxKeyRequestURL is used to select the request URL from a context. CtxKeyRequestURL // CtxKeyRequestBody is used to select the request body from a context. CtxKeyRequestBody // CtxKeyTraceID is used to select the trace ID from a context. CtxKeyTraceID // CtxKeySpanID is used to select the tracing span ID from a context. CtxKeySpanID // CtxKeyRemote is used to select a remote address from a context. CtxKeyRemote // CtxKeyNoCache is used to select the no-cache flag from a context. CtxKeyNoCache // CtxKeyJWT is used to select the authentication token from a context. CtxKeyJWT // CtxKeyScopes is used to select the authorization scopes from a context. CtxKeyScopes // CtxKeyAccountID is used to select the account id from a context. CtxKeyAccountID // CtxKeyUserID is used to select the user id from a context. CtxKeyUserID )
type FieldBool ¶
FieldBool values represent booleans tolerant of JSON inputs.
func (*FieldBool) MarshalBSON ¶
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldBool) MarshalJSON ¶
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldBool) MarshalYAML ¶
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldBool) UnmarshalBSON ¶
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldBool) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON format byte slice into this value.
type FieldDuration ¶
FieldDuration values represent integers tolerant of JSON inputs.
func (*FieldDuration) MarshalBSON ¶
func (f *FieldDuration) MarshalBSON() ([]byte, error)
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldDuration) MarshalJSON ¶
func (f *FieldDuration) MarshalJSON() ([]byte, error)
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldDuration) MarshalYAML ¶
func (f FieldDuration) MarshalYAML() (any, error)
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldDuration) Scan ¶
func (f *FieldDuration) Scan(src any) error
Scan allows this value to be used in database/sql scan functions.
func (*FieldDuration) String ¶
func (f *FieldDuration) String() string
String returns the value as a string.
func (*FieldDuration) UnmarshalBSON ¶
func (f *FieldDuration) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldDuration) UnmarshalJSON ¶
func (f *FieldDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes a JSON format byte slice into this value.
func (*FieldDuration) UnmarshalYAML ¶
func (f *FieldDuration) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML decodes a YAML format byte slice into this value.
type FieldFloat64 ¶
FieldFloat64 values represent floats tolerant of JSON inputs.
func (*FieldFloat64) MarshalBSON ¶
func (f *FieldFloat64) MarshalBSON() ([]byte, error)
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldFloat64) MarshalJSON ¶
func (f *FieldFloat64) MarshalJSON() ([]byte, error)
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldFloat64) MarshalYAML ¶
func (f FieldFloat64) MarshalYAML() (any, error)
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldFloat64) Scan ¶
func (f *FieldFloat64) Scan(src any) error
Scan allows this value to be used in database/sql scan functions.
func (*FieldFloat64) String ¶
func (f *FieldFloat64) String() string
String returns the value as a string.
func (*FieldFloat64) UnmarshalBSON ¶
func (f *FieldFloat64) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldFloat64) UnmarshalJSON ¶
func (f *FieldFloat64) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes a JSON format byte slice into this value.
func (*FieldFloat64) UnmarshalYAML ¶
func (f *FieldFloat64) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML decodes a YAML format byte slice into this value.
type FieldInt64 ¶
FieldInt64 values represent integers tolerant of JSON inputs.
func (*FieldInt64) MarshalBSON ¶
func (f *FieldInt64) MarshalBSON() ([]byte, error)
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldInt64) MarshalJSON ¶
func (f *FieldInt64) MarshalJSON() ([]byte, error)
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldInt64) MarshalYAML ¶
func (f FieldInt64) MarshalYAML() (any, error)
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldInt64) Scan ¶
func (f *FieldInt64) Scan(src any) error
Scan allows this value to be used in database/sql scan functions.
func (*FieldInt64) String ¶
func (f *FieldInt64) String() string
String returns the value as a string.
func (*FieldInt64) UnmarshalBSON ¶
func (f *FieldInt64) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldInt64) UnmarshalJSON ¶
func (f *FieldInt64) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes a JSON format byte slice into this value.
func (*FieldInt64) UnmarshalYAML ¶
func (f *FieldInt64) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML decodes a YAML format byte slice into this value.
type FieldInt64Array ¶
FieldInt64Array values represent string arrays tolerant of JSON inputs.
func (*FieldInt64Array) MarshalBSON ¶
func (f *FieldInt64Array) MarshalBSON() ([]byte, error)
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldInt64Array) MarshalJSON ¶
func (f *FieldInt64Array) MarshalJSON() ([]byte, error)
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldInt64Array) MarshalYAML ¶
func (f FieldInt64Array) MarshalYAML() (any, error)
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldInt64Array) String ¶
func (f *FieldInt64Array) String() string
String returns the value as a string.
func (*FieldInt64Array) UnmarshalBSON ¶
func (f *FieldInt64Array) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldInt64Array) UnmarshalJSON ¶
func (f *FieldInt64Array) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes a JSON format byte slice into this value.
func (*FieldInt64Array) UnmarshalYAML ¶
func (f *FieldInt64Array) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML decodes a YAML format byte slice into this value.
type FieldJSON ¶
FieldJSON values represent unparsed JSON objects.
func (*FieldJSON) MarshalBSON ¶
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldJSON) MarshalJSON ¶
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldJSON) MarshalYAML ¶
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldJSON) UnmarshalBSON ¶
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldJSON) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON format byte slice into this value.
type FieldString ¶
FieldString values represent strings tolerant of JSON inputs.
func (*FieldString) MarshalBSON ¶
func (f *FieldString) MarshalBSON() ([]byte, error)
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldString) MarshalJSON ¶
func (f *FieldString) MarshalJSON() ([]byte, error)
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldString) MarshalYAML ¶
func (f FieldString) MarshalYAML() (any, error)
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldString) Scan ¶
func (f *FieldString) Scan(src any) error
Scan allows this value to be used in database/sql scan functions.
func (*FieldString) String ¶
func (f *FieldString) String() string
String returns the value as a string.
func (*FieldString) UnmarshalBSON ¶
func (f *FieldString) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldString) UnmarshalJSON ¶
func (f *FieldString) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes a JSON format byte slice into this value.
func (*FieldString) UnmarshalYAML ¶
func (f *FieldString) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML decodes a YAML format byte slice into this value.
type FieldStringArray ¶
FieldStringArray values represent string arrays tolerant of JSON inputs.
func (*FieldStringArray) MarshalBSON ¶
func (f *FieldStringArray) MarshalBSON() ([]byte, error)
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldStringArray) MarshalJSON ¶
func (f *FieldStringArray) MarshalJSON() ([]byte, error)
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldStringArray) MarshalYAML ¶
func (f FieldStringArray) MarshalYAML() (any, error)
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldStringArray) String ¶
func (f *FieldStringArray) String() string
String returns the value as a string.
func (*FieldStringArray) UnmarshalBSON ¶
func (f *FieldStringArray) UnmarshalBSON(b []byte) error
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldStringArray) UnmarshalJSON ¶
func (f *FieldStringArray) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes a JSON format byte slice into this value.
func (*FieldStringArray) UnmarshalYAML ¶
func (f *FieldStringArray) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML decodes a YAML format byte slice into this value.
type FieldTime ¶
FieldTime values represent timestamps tolerant of JSON inputs.
func (*FieldTime) MarshalBSON ¶
MarshalBSON encodes this value into a BSON format byte slice.
func (*FieldTime) MarshalJSON ¶
MarshalJSON encodes this value into a JSON format byte slice.
func (FieldTime) MarshalYAML ¶
MarshalYAML encodes a this value into a YAML format byte slice.
func (*FieldTime) UnmarshalBSON ¶
UnmarshalBSON decodes a BSON format byte slice into this value.
func (*FieldTime) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON format byte slice into this value.