Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrContextNotFound = errors.New("context not found")
ErrContextNotFound is returned when JSON-LD context document is not found in the underlying storage.
Functions ¶
This section is empty.
Types ¶
type DocumentLoader ¶
type DocumentLoader struct {
// contains filtered or unexported fields
}
DocumentLoader is an implementation of ld.DocumentLoader backed by storage.
func NewDocumentLoader ¶
func NewDocumentLoader(ctx provider, opts ...DocumentLoaderOpts) (*DocumentLoader, error)
NewDocumentLoader returns a new DocumentLoader instance.
Embedded contexts (`ldcontext/embed/third_party`) are preloaded into the underlying storage. Additional contexts can be set using WithExtraContexts() option or provided by one or more remote providers. Use multiple WithRemoteProvider() options for setting up more than one remote JSON-LD context provider.
By default, missing contexts are not fetched from the remote URL. Use WithRemoteDocumentLoader() option to specify a custom loader that can resolve context documents from the network.
func (*DocumentLoader) LoadDocument ¶
func (l *DocumentLoader) LoadDocument(u string) (*jsonld.RemoteDocument, error)
LoadDocument resolves JSON-LD context document by document URL (u) either from storage or from remote URL. If document is not found in the storage and remote DocumentLoader is not specified, ErrContextNotFound is returned.
type DocumentLoaderOpts ¶
type DocumentLoaderOpts func(opts *documentLoaderOpts)
DocumentLoaderOpts configures DocumentLoader during creation.
func WithExtraContexts ¶
func WithExtraContexts(contexts ...ldcontext.Document) DocumentLoaderOpts
WithExtraContexts sets the extra contexts (in addition to embedded) for preloading into the underlying storage.
func WithRemoteDocumentLoader ¶
func WithRemoteDocumentLoader(loader jsonld.DocumentLoader) DocumentLoaderOpts
WithRemoteDocumentLoader specifies loader for fetching JSON-LD context documents from remote URLs. Documents are fetched with this loader only if they are not found in the underlying storage.
func WithRemoteProvider ¶
func WithRemoteProvider(provider RemoteProvider) DocumentLoaderOpts
WithRemoteProvider adds a remote JSON-LD context provider to the list of providers.