qri: github.com/qri-io/qri/api Index | Files

package api

import "github.com/qri-io/qri/api"

Package api implements a JSON-API for interacting with a qri node


Package Files

api.go context.go datasets.go fsi.go log.go middleware.go peers.go profile.go registry.go remote.go render.go root.go search.go templates.go transports.go update.go websocket.go


const LocalHostIP = ""

LocalHostIP is the IP address for localhost


var APIVersion = version.String

APIVersion is the version string that is written in API responses

func DatasetRefFromCtx Uses

func DatasetRefFromCtx(ctx context.Context) repo.DatasetRef

DatasetRefFromCtx extracts a Dataset reference from a given context if one is set, returning nil otherwise

func DatasetRefFromPath Uses

func DatasetRefFromPath(path string) (repo.DatasetRef, error)

DatasetRefFromPath parses a path and returns a datasetRef

func DatasetRefFromReq Uses

func DatasetRefFromReq(r *http.Request) (repo.DatasetRef, error)

DatasetRefFromReq examines the path element of a request URL to

func HTTPPathToQriPath Uses

func HTTPPathToQriPath(path string) string

HTTPPathToQriPath converts a http path to a qri path

func HTTPSRedirect Uses

func HTTPSRedirect(addr string)

HTTPSRedirect listens over TCP on addr, redirecting HTTP requests to https

func HealthCheckHandler Uses

func HealthCheckHandler(w http.ResponseWriter, r *http.Request)

HealthCheckHandler is a basic ok response for load balancers & co returns the version of qri this node is running, pulled from the lib package

func NewServerRoutes Uses

func NewServerRoutes(s Server) *http.ServeMux

NewServerRoutes returns a Muxer that has all API routes

func StartServer Uses

func StartServer(c *config.API, s *http.Server) error

StartServer interprets info from config to start the server if config.TLS == true it'll spin up an https server using LetsEncrypt that should work just fine on the raw internet (ie not behind a proxy like nginx etc) it'll also redirect http traffic to it's https route counterpart if port 80 is open

type DataResponse Uses

type DataResponse struct {
    Path string          `json:"path"`
    Data json.RawMessage `json:"data"`

DataResponse is the struct used to respond to api requests made to the /data endpoint It is necessary because we need to include the 'path' field in the response

type DatasetHandlers Uses

type DatasetHandlers struct {

    ReadOnly bool
    // contains filtered or unexported fields

DatasetHandlers wraps a requests struct to interface with http.HandlerFunc

func NewDatasetHandlers Uses

func NewDatasetHandlers(inst *lib.Instance, readOnly bool) *DatasetHandlers

NewDatasetHandlers allocates a DatasetHandlers pointer

func (*DatasetHandlers) AddHandler Uses

func (h *DatasetHandlers) AddHandler(w http.ResponseWriter, r *http.Request)

AddHandler is an endpoint for creating new datasets

func (*DatasetHandlers) BodyHandler Uses

func (h *DatasetHandlers) BodyHandler(w http.ResponseWriter, r *http.Request)

BodyHandler gets the contents of a dataset

func (*DatasetHandlers) DiffHandler Uses

func (h *DatasetHandlers) DiffHandler(w http.ResponseWriter, r *http.Request)

DiffHandler is a dataset single endpoint

func (*DatasetHandlers) GetHandler Uses

func (h *DatasetHandlers) GetHandler(w http.ResponseWriter, r *http.Request)

GetHandler is a dataset single endpoint

func (*DatasetHandlers) ListHandler Uses

func (h *DatasetHandlers) ListHandler(w http.ResponseWriter, r *http.Request)

ListHandler is a dataset list endpoint

func (*DatasetHandlers) PeerListHandler Uses

func (h *DatasetHandlers) PeerListHandler(w http.ResponseWriter, r *http.Request)

PeerListHandler is a dataset list endpoint

func (*DatasetHandlers) RemoveHandler Uses

func (h *DatasetHandlers) RemoveHandler(w http.ResponseWriter, r *http.Request)

RemoveHandler is a a dataset delete endpoint

func (*DatasetHandlers) RenameHandler Uses

func (h *DatasetHandlers) RenameHandler(w http.ResponseWriter, r *http.Request)

RenameHandler is the endpoint for renaming datasets

func (*DatasetHandlers) SaveHandler Uses

func (h *DatasetHandlers) SaveHandler(w http.ResponseWriter, r *http.Request)

SaveHandler is a dataset save/update endpoint

func (*DatasetHandlers) StatsHandler Uses

func (h *DatasetHandlers) StatsHandler(w http.ResponseWriter, r *http.Request)

StatsHandler gets stats about the dataset

func (*DatasetHandlers) UnpackHandler Uses

func (h *DatasetHandlers) UnpackHandler(w http.ResponseWriter, r *http.Request)

UnpackHandler unpacks a zip file and sends it back as json

func (*DatasetHandlers) ZipDatasetHandler Uses

func (h *DatasetHandlers) ZipDatasetHandler(w http.ResponseWriter, r *http.Request)

ZipDatasetHandler is the endpoint for getting a zip archive of a dataset

type FSIHandlers Uses

type FSIHandlers struct {

    ReadOnly bool
    // contains filtered or unexported fields

FSIHandlers connects HTTP requests to the FSI subsystem

func NewFSIHandlers Uses

func NewFSIHandlers(inst *lib.Instance, readOnly bool) FSIHandlers

NewFSIHandlers creates handlers that talk to qri's filesystem integration

func (*FSIHandlers) CheckoutHandler Uses

func (h *FSIHandlers) CheckoutHandler(routePrefix string) http.HandlerFunc

CheckoutHandler invokes checkout via an API call

func (*FSIHandlers) InitHandler Uses

func (h *FSIHandlers) InitHandler(routePrefix string) http.HandlerFunc

InitHandler creates a new FSI-linked dataset

func (*FSIHandlers) RestoreHandler Uses

func (h *FSIHandlers) RestoreHandler(routePrefix string) http.HandlerFunc

RestoreHandler invokes restore via an API call

func (*FSIHandlers) StatusHandler Uses

func (h *FSIHandlers) StatusHandler(routePrefix string) http.HandlerFunc

StatusHandler is the endpoint for getting the status of a linked dataset

func (*FSIHandlers) WriteHandler Uses

func (h *FSIHandlers) WriteHandler(routePrefix string) http.HandlerFunc

WriteHandler writes input data to the local filesystem link

type LogHandlers Uses

type LogHandlers struct {

LogHandlers wraps a LogRequests with http.HandlerFuncs

func NewLogHandlers Uses

func NewLogHandlers(n *p2p.QriNode) *LogHandlers

NewLogHandlers allocates a LogHandlers pointer

func (*LogHandlers) LogHandler Uses

func (h *LogHandlers) LogHandler(w http.ResponseWriter, r *http.Request)

LogHandler is the endpoint for dataset logs

type PeerHandlers Uses

type PeerHandlers struct {
    ReadOnly bool

PeerHandlers wraps a requests struct to interface with http.HandlerFunc

func NewPeerHandlers Uses

func NewPeerHandlers(node *p2p.QriNode, readOnly bool) *PeerHandlers

NewPeerHandlers allocates a PeerHandlers pointer

func (*PeerHandlers) ConnectToPeerHandler Uses

func (h *PeerHandlers) ConnectToPeerHandler(w http.ResponseWriter, r *http.Request)

ConnectToPeerHandler is the endpoint for explicitly connecting to a peer

func (*PeerHandlers) ConnectionsHandler Uses

func (h *PeerHandlers) ConnectionsHandler(w http.ResponseWriter, r *http.Request)

ConnectionsHandler is the endpoint for listing qri & IPFS connections

func (*PeerHandlers) PeerHandler Uses

func (h *PeerHandlers) PeerHandler(w http.ResponseWriter, r *http.Request)

PeerHandler gets info on a single peer

func (*PeerHandlers) PeersHandler Uses

func (h *PeerHandlers) PeersHandler(w http.ResponseWriter, r *http.Request)

PeersHandler is the endpoint for fetching peers

type ProfileHandlers Uses

type ProfileHandlers struct {
    ReadOnly bool

ProfileHandlers wraps a requests struct to interface with http.HandlerFunc

func NewProfileHandlers Uses

func NewProfileHandlers(inst *lib.Instance, readOnly bool) *ProfileHandlers

NewProfileHandlers allocates a ProfileHandlers pointer

func (*ProfileHandlers) PosterHandler Uses

func (h *ProfileHandlers) PosterHandler(w http.ResponseWriter, r *http.Request)

PosterHandler is the endpoint for uploading this peer's poster photo

func (*ProfileHandlers) ProfileHandler Uses

func (h *ProfileHandlers) ProfileHandler(w http.ResponseWriter, r *http.Request)

ProfileHandler is the endpoint for this peer's profile

func (*ProfileHandlers) ProfilePhotoHandler Uses

func (h *ProfileHandlers) ProfilePhotoHandler(w http.ResponseWriter, r *http.Request)

ProfilePhotoHandler is the endpoint for uploading this peer's profile photo

type QriCtxKey Uses

type QriCtxKey string

QriCtxKey defines a distinct type for keys for context values should always use custom types to avoid collissions. see comment on context.WithValue for more info

const DatasetRefCtxKey QriCtxKey = "datasetRef"

DatasetRefCtxKey is the key for adding a dataset reference to a context.Context

type RegistryClientHandlers Uses

type RegistryClientHandlers struct {
    // contains filtered or unexported fields

RegistryClientHandlers wraps a requests struct to interface with http.HandlerFunc

func NewRegistryClientHandlers Uses

func NewRegistryClientHandlers(inst *lib.Instance, readOnly bool) *RegistryClientHandlers

NewRegistryClientHandlers allocates a RegistryClientHandlers pointer

func (*RegistryClientHandlers) CreateProfileHandler Uses

func (h *RegistryClientHandlers) CreateProfileHandler(w http.ResponseWriter, r *http.Request)

CreateProfileHandler creates a profile, associating it with a private key

func (*RegistryClientHandlers) ProveProfileKeyHandler Uses

func (h *RegistryClientHandlers) ProveProfileKeyHandler(w http.ResponseWriter, r *http.Request)

ProveProfileKeyHandler proves a user controls both a registry profile and a new keypair

type RemoteClientHandlers Uses

type RemoteClientHandlers struct {
    // contains filtered or unexported fields

RemoteClientHandlers provides HTTP handlers for issuing requests to remotes

func NewRemoteClientHandlers Uses

func NewRemoteClientHandlers(inst *lib.Instance, readOnly bool) *RemoteClientHandlers

NewRemoteClientHandlers creates remote client Handlers from a qri instance

func (*RemoteClientHandlers) NewFetchHandler Uses

func (h *RemoteClientHandlers) NewFetchHandler(prefix string) http.HandlerFunc

NewFetchHandler returns an HTTP handler for fetching details from a remote

func (*RemoteClientHandlers) PublishHandler Uses

func (h *RemoteClientHandlers) PublishHandler(w http.ResponseWriter, r *http.Request)

PublishHandler facilitates requests to publish or unpublish from the local node to a remote

type RemoteHandlers Uses

type RemoteHandlers struct {
    DsyncHandler   http.HandlerFunc
    RefsHandler    http.HandlerFunc
    LogsyncHandler http.HandlerFunc

RemoteHandlers wraps a request struct to interface with http.HandlerFunc

func NewRemoteHandlers Uses

func NewRemoteHandlers(inst *lib.Instance) *RemoteHandlers

NewRemoteHandlers allocates a RemoteHandlers pointer

type RenameReqParams Uses

type RenameReqParams struct {
    Current string
    New     string

RenameReqParams is an encoding struct its intent is to be a more user-friendly structure for the api endpoint that will map to and from the lib.RenameParams struct

type RenderHandlers Uses

type RenderHandlers struct {
    // contains filtered or unexported fields

RenderHandlers wraps a requests struct to interface with http.HandlerFunc

func NewRenderHandlers Uses

func NewRenderHandlers(r repo.Repo) *RenderHandlers

NewRenderHandlers allocates a RenderHandlers pointer

func (*RenderHandlers) RenderHandler Uses

func (h *RenderHandlers) RenderHandler(w http.ResponseWriter, r *http.Request)

RenderHandler renders a given dataset ref

type RootHandler Uses

type RootHandler struct {
    // contains filtered or unexported fields

RootHandler bundles handlers that may need to be called by "/" TODO - This will be removed when we add a proper router

func NewRootHandler Uses

func NewRootHandler(dsh *DatasetHandlers, ph *PeerHandlers) *RootHandler

NewRootHandler creates a new RootHandler

func (*RootHandler) Handler Uses

func (mh *RootHandler) Handler(w http.ResponseWriter, r *http.Request)

Handler is the only Handler func for the RootHandler struct

type SearchHandlers Uses

type SearchHandlers struct {

SearchHandlers wraps a requests struct to interface with http.HandlerFunc

func NewSearchHandlers Uses

func NewSearchHandlers(inst *lib.Instance) *SearchHandlers

NewSearchHandlers allocates a SearchHandlers pointer

func (*SearchHandlers) SearchHandler Uses

func (h *SearchHandlers) SearchHandler(w http.ResponseWriter, r *http.Request)

SearchHandler is the endpoint for searching qri

type Server Uses

type Server struct {

Server wraps a qri p2p node, providing traditional access via http Create one with New, start it up with Serve

func New Uses

func New(inst *lib.Instance) (s Server)

New creates a new qri server from a p2p node & configuration

func (*Server) HandleIPFSPath Uses

func (s *Server) HandleIPFSPath(w http.ResponseWriter, r *http.Request)

HandleIPFSPath responds to IPFS Hash requests with raw data

func (Server) HandleIPNSPath Uses

func (s Server) HandleIPNSPath(w http.ResponseWriter, r *http.Request)

HandleIPNSPath resolves an IPNS entry

func (Server) Serve Uses

func (s Server) Serve(ctx context.Context) (err error)

Serve starts the server. It will block while the server is running

func (Server) ServeRPC Uses

func (s Server) ServeRPC(ctx context.Context)

ServeRPC checks for a configured RPC port, and registers a listner if so

func (Server) ServeWebsocket Uses

func (s Server) ServeWebsocket(ctx context.Context)

ServeWebsocket creates a websocket that clients can connect to in order to get realtime events

type UpdateHandlers Uses

type UpdateHandlers struct {
    ReadOnly bool

UpdateHandlers wraps lib.UpdateMethods, adding HTTP JSON API handles

func (*UpdateHandlers) LogFileHandler Uses

func (h *UpdateHandlers) LogFileHandler(w http.ResponseWriter, r *http.Request)

LogFileHandler fetches log output file data

func (*UpdateHandlers) LogsHandler Uses

func (h *UpdateHandlers) LogsHandler(w http.ResponseWriter, r *http.Request)

LogsHandler shows the log of previously run updates

func (UpdateHandlers) RunHandler Uses

func (h UpdateHandlers) RunHandler(w http.ResponseWriter, r *http.Request)

RunHandler brings a dataset to the latest version

func (UpdateHandlers) ServiceHandler Uses

func (h UpdateHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request)

ServiceHandler configures & reports on the update daemon

func (*UpdateHandlers) UpdatesHandler Uses

func (h *UpdateHandlers) UpdatesHandler(w http.ResponseWriter, r *http.Request)

UpdatesHandler brings a dataset to the latest version

Package api imports 36 packages (graph) and is imported by 1 packages. Updated 2020-01-03. Refresh now. Tools for package owners.