Provides access to the current application from context; returns Application or error if not found.
// Source: https://github.com/iota-uz/iota-sdk | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Package application provides this package.
package application
import (
"context"
"errors"
"github.com/iota-uz/iota-sdk/pkg/constants"
)
var (
ErrAppNotFound = errors.New("app not found")
)
// UseApp returns the user from the context.
// If the user is not found, the second return value will be false.
func UseApp(ctx context.Context) (Application, error) {
app := ctx.Value(constants.AppKey)
if app == nil {
return nil, ErrAppNotFound
}
return app.(Application), nil
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key