{"modulePath":"github.com/codedellemc/libstorage","version":"v0.6.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package context\n\n## Functions\n\n```go\nfunc AuthToken(ctx context.Context) (*types.AuthToken, bool)\n```\nAuthToken returns the context's security token. This value is valid on both the client and the server.\n\n```go\nfunc Background() types.Context\n```\nBackground returns a new context with logging capabilities.\n\n```go\nfunc Client(ctx context.Context) (types.Client, bool)\n```\nClient returns the context's Client. This value is only valid for contexts created on the client.\n\n```go\nfunc CustomHeaderKeys() \u003c-chan interface{}\n```\nCustomHeaderKeys returns a channel on which can be received all the registered, custom header keys.\n\n```go\nfunc CustomLoggerKeys() \u003c-chan interface{}\n```\nCustomLoggerKeys returns a channel on which can be received all the registered, custom logger keys.\n\n```go\nfunc Driver(ctx context.Context) (types.StorageDriver, bool)\n```\nDriver returns the context's storage driver. This value is valid only on the server and subject to the same restrictions as listed in the Service function.\n\n```go\nfunc GetLogLevel(ctx context.Context) (log.Level, bool)\n```\nGetLogLevel gets the context's log level.\n\n```go\nfunc InstanceID(ctx context.Context) (*types.InstanceID, bool)\n```\nInstanceID returns the context's InstanceID. This value is valid on both the client and the server.\n\n```go\nfunc Join(left types.Context, right context.Context) types.Context\n```\nJoin joins this context with another, such that value lookups will first first check the current context, and if no such value exist, a lookup will be performed against the right side.\n\n```go\nfunc LocalDevices(ctx context.Context) (*types.LocalDevices, bool)\n```\nLocalDevices returns the context's local devices map. This value is valid on both the client and the server.\n\n```go\nfunc MustAuthToken(ctx context.Context) *types.AuthToken\n```\nMustAuthToken returns the context's security token and panics if it does not exist and/or cannot be type cast.\n\n```go\nfunc MustClient(ctx context.Context) types.Client\n```\nMustClient returns the context's Client and panics if the client is not available and/or not castable..\n\n```go\nfunc MustDriver(ctx context.Context) types.StorageDriver\n```\nMustDriver returns the context's storage driver or panics if no driver exists.\n\n```go\nfunc MustInstanceID(ctx context.Context) *types.InstanceID\n```\nMustInstanceID returns the context's InstanceID and panics if it does not exist and/or cannot be type cast.\n\n```go\nfunc MustPathConfig(ctx context.Context) *types.PathConfig\n```\nMustPathConfig returns the context's path config and panics if it does not exist and/or cannot be type cast.\n\n```go\nfunc MustService(ctx context.Context) types.StorageService\n```\nMustService returns the context's StorageService  and panics if it does not exist and/or cannot be type cast.\n\n```go\nfunc MustSession(ctx context.Context) interface{}\n```\nMustSession returns the context's session object and panics if a session does not exist.\n\n```go\nfunc MustTransaction(ctx context.Context) *types.Transaction\n```\nMustTransaction returns the context's Transaction and will panic if the value is missing or not castable.\n\n```go\nfunc New(parent context.Context) types.Context\n```\nNew returns a new context with the provided parent.\n\n```go\nfunc PathConfig(ctx context.Context) (*types.PathConfig, bool)\n```\nPathConfig returns the context's path config. This value is valid on both the client and the server.\n\n```go\nfunc Profile(ctx context.Context) (string, bool)\n```\nProfile returns the context's profile. This value is only valid for contexts created on the server after the profile handler has been executred.\n\n```go\nfunc RegisterCustomKey(key interface{}, mask CustomKeyTypes) error\n```\nRegisterCustomKey registers a custom key with the context package.\n\n```go\nfunc RegisterCustomKeyWithContext(\n\tctx types.Context, key interface{}, mask CustomKeyTypes) error\n```\nRegisterCustomKeyWithContext registers a custom key with the context package.\n\n```go\nfunc RequireTX(ctx context.Context) types.Context\n```\nRequireTX ensures a context has a transaction, and if it doesn't creates a new one.\n\n```go\nfunc Route(ctx context.Context) (types.Route, bool)\n```\nRoute returns the context's route. This value is only valid for contexts created on the server after a mux has received an incoming HTTP request. Any part of the libStorage workflow after that, including the handlers, routers, and storage drivers, should have access to the Route.\n\n```go\nfunc Server(ctx context.Context) (string, bool)\n```\nServer returns the context's server name. This value is valid on both the client and the server.\n\n```go\nfunc Service(ctx context.Context) (types.StorageService, bool)\n```\nService returns the context's storage service. This value is valid only for contexts created on the server. The value is only available after the service has been injected as part of the ServiceValidator handler or by one of the routes that injects it manually such as Volumes or Snapshots.\n\n```go\nfunc ServiceName(ctx context.Context) (string, bool)\n```\nServiceName returns the context's service name. This value is valid for contexts created on both the client and the server. On the server this value is subject to the same restrictions as listed in the Service function.\n\n```go\nfunc Session(ctx context.Context) (interface{}, bool)\n```\nSession returns the context's session object. This value is valid only on the server.\n\n```go\nfunc SetLogLevel(ctx context.Context, lvl log.Level)\n```\nSetLogLevel sets the context's log level.\n\n```go\nfunc Transaction(ctx context.Context) (*types.Transaction, bool)\n```\nTransaction returns the context's Transaction. This value is valid on both the client and the server.\n\n```go\nfunc Value(ctx context.Context, key interface{}) interface{}\n```\nValue returns the value associated with this context for key, or nil if no value is associated with key.  Successive calls to Value with the same key returns the same result.\n\n```go\nfunc WithRequestRoute(\n\tparent context.Context,\n\treq *http.Request,\n\troute types.Route) types.Context\n```\nWithRequestRoute returns a new context with the injected \\*http.Request and Route.\n\n```go\nfunc WithStorageService(\n\tparent context.Context, service types.StorageService) types.Context\n```\nWithStorageService returns a new context with the StorageService as the value and attempts to assign the service's associated InstanceID and LocalDevices (by way of the service's StorageDriver) to the context as well.\n\n```go\nfunc WithStorageSession(parent context.Context) (types.Context, error)\n```\nWithStorageSession returns a context that is logged into the storage platform.\n\n```go\nfunc WithValue(ctx context.Context, key, val interface{}) types.Context\n```\nWithValue returns a copy of parent in which the value associated with key is val.\n\n## Types\n\n```go\ntype CustomKeyTypes int\n```\nCustomKeyTypes is a bitmask used when registering a custom key with the context at runtime.\n\n```go\nconst (\n\t// CustomLoggerKey indicates a value set for this key should be logged as\n\t// a member of a log entry's fields collection when using the context's\n\t// structured logger.\n\tCustomLoggerKey CustomKeyTypes = 1 \u003c\u003c iota\n\n\t// CustomHeaderKey indicates a value set for this key should be sent along\n\t// with HTTP requests as an HTTP header.\n\tCustomHeaderKey\n)\n```\n\n```go\ntype Key int\n```\nKey is the type used as a context key.\n\n```go\nconst (\n\n\t// PathConfigKey is a context key.\n\tPathConfigKey Key\n\n\t// LoggerKey is a context key.\n\tLoggerKey\n\n\t// HTTPRequestKey is a context key.\n\tHTTPRequestKey\n\n\t// AllInstanceIDsKey is the key for the map[string]*types.InstanceID value\n\t// that maps all drivers to their instance IDs.\n\tAllInstanceIDsKey\n\n\t// LocalDevicesKey is a context key.\n\tLocalDevicesKey\n\n\t// AllLocalDevicesKey is the key for the map[string]*types.LocalDevices\n\t// value that maps all drivers to their instance IDs.\n\tAllLocalDevicesKey\n\n\t// AdminTokenKey is the key for the server's admin token.\n\tAdminTokenKey\n\n\t// SessionKey is the key for the storage driver's session.\n\tSessionKey\n\n\t// EncodedAuthTokenKey is the key for an encoded authentication token.\n\tEncodedAuthTokenKey\n\n\t// AuthTokenKey is a context key.\n\tAuthTokenKey\n\n\t// ClientKey is a context key.\n\tClientKey\n\n\t// TaskKey is a context key.\n\tTaskKey\n\n\t// InstanceIDKey is a context key.\n\tInstanceIDKey\n\n\t// ProfileKey is a context key.\n\tProfileKey\n\n\t// RouteKey is a context key.\n\tRouteKey\n\n\t// ServerKey is a context key.\n\tServerKey\n\n\t// ServiceKey is an alias for StorageService.\n\tServiceKey\n\n\t// StorageServiceKey is a context key.\n\tStorageServiceKey\n\n\t// TransactionKey is a context key.\n\tTransactionKey\n\n\t// DriverKey is an alias for StorageDriver.\n\tDriverKey\n\n\t// UserKey is a context key.\n\tUserKey\n\n\t// HostKey is a context key.\n\tHostKey\n\n\t// TLSKey is a context key.\n\tTLSKey\n)\n```\n\n```go\nfunc (k Key) String() string\n```\nString returns the name of the context key.\n\n","path":"github.com/codedellemc/libstorage/api/context","name":"context","synopsis":"","isRedistributable":true}
