loader

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2019 License: MIT Imports: 11 Imported by: 0

README

go-ld-loader

Sometimes you want to be sure that the remote JSON-LD contexts you're loading are really the ones the author intended, and a good way of doing this is content-addressed contexts using ipfs:// or dweb:/ipfs/ URI schemes.

This module has two interfaces that satisfy the ld.DocumentLoader interface from github.com/piprate/json-gold - a HTTPDocumentLoader that uses the HTTP API interface from github.com/ipfs/go-ipfs-api, and a CoreDocumentLoader that uses the CoreAPI instance from github.com/ipfs/interface-go-ipfs-core, which is what you get passed if you write a go-ipfs plugin.

Usage should be fairly straightforward. raw, json, and dag-cbor IPLD formats are supported with dweb:/ipld/ URIs if you want to be really compact.

Documentation

Index

Constants

View Source
const DefaultHTTPAddress = "localhost:5001"

DefaultHTTPAddress is the default shell address

Variables

This section is empty.

Functions

This section is empty.

Types

type CoreDocumentLoader

type CoreDocumentLoader struct {
	// contains filtered or unexported fields
}

CoreDocumentLoader is an implementation of ld.DocumentLoader for ipfs:// and dweb:/ipfs/ URIs that an core.CoreAPI

func NewCoreDocumentLoader

func NewCoreDocumentLoader(api core.CoreAPI) *CoreDocumentLoader

NewCoreDocumentLoader creates a new instance of DwebDocumentLoader

func (*CoreDocumentLoader) LoadDocument

func (dl *CoreDocumentLoader) LoadDocument(uri string) (*ld.RemoteDocument, error)

LoadDocument returns a RemoteDocument containing the contents of the JSON-LD resource from the given URL.

type HTTPDocumentLoader

type HTTPDocumentLoader struct {
	// contains filtered or unexported fields
}

HTTPDocumentLoader is an implementation of ld.DocumentLoader for ipfs:// and dweb:/ipfs/ URIs that uses an ipfs.HTTP

func NewHTTPDocumentLoader

func NewHTTPDocumentLoader(shell *ipfs.Shell) *HTTPDocumentLoader

NewHTTPDocumentLoader creates a new instance of HTTPDocumentLoader

func (*HTTPDocumentLoader) LoadDocument

func (dl *HTTPDocumentLoader) LoadDocument(uri string) (*ld.RemoteDocument, error)

LoadDocument returns a RemoteDocument containing the contents of the JSON-LD resource from the given URL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL