Documentation ¶
Overview ¶
Package repo provides a simple http client for interacting with sparql endpoints.
It comes with a series of convenience options for setting auth, or caching responses.
The client contained in this package also serves as a reference implementation for any developer who has more complex requirements than this very simple client provides
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBasicAuth ¶
WithBasicAuth configures Repo to use basic authentication on HTTP requests.
func WithCache ¶
WithCache takes a httpcache.Cache, thus providing a way of caching sparql queries which may be otherwise slow, or where the data returned changes infrequently.
It may be used as:
cache := httpcache.NewMemoryCache() repo := sparql.NewRepo("localhost:8080/sparql", sparql.WithCache(cache))
This uses the default httpcache in-memory cache in requests
func WithDigestAuth ¶
WithDigestAuth configures Repo to use digest authentication on HTTP requests.
func WithHeader ¶
WithHeader sets a header on requests to a repo
These headers can be chained, both with themselves and with another set of repo opts, such as
repo, err := repo.New("https://example.com", repo.WithCache(c), repo.WithHeader("max-age", "1800"), repo.WithHeader("user-agent", "my-app"))
It's better to set these options last though, just in case a prior opt mucks about with headers or clients or roundtrippers
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo represents a RDF repository, assumed to be queryable via the SPARQL protocol over HTTP.
func New ¶
New creates a new representation of a RDF repository. It takes a variadic list of functional options which can alter the configuration of the repository.
func (Repo) Query ¶
Query performs a SPARQL HTTP request to the Repo, and returns the parsed application/sparql-results+json response.
These lookups are expected to be idempotent, and as such use http.MethodGet requests. See: Repo.Update for requests which use http.MethodPost
func (*Repo) SetOption ¶
SetOption takes one or more option function and applies them in order to Repo.
func (Repo) Update ¶
Update performs a SPARQL HTTP request to the Repo, and returns the parsed application/sparql-results+json response.
These queries are made via an http.MethodPost and, so, are expected to change state.
Functionally these requests differ very little from requests made via Repo.Query; and in fact there's nothing that says a POST'd request *must* update state. The difference is purely to allow for the caching of GET requests