api

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 40 Imported by: 1

Documentation

Overview

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

Index

Constants

View Source
const (
	LocalHostIP = "127.0.0.1"
	// DefaultTemplateHash is the hash of the default render template
	DefaultTemplateHash = "/ipfs/QmeqeRTf2Cvkqdx4xUdWi1nJB2TgCyxmemsL3H4f1eTBaw"
	// TemplateUpdateAddress is the URI for the template update
	TemplateUpdateAddress = "/ipns/defaulttmpl.qri.io"
)

LocalHostIP is the IP address for localhost

View Source
const DefaultWebappPort = 2505

DefaultWebappPort is the default port the web app will listen on

Variables

View Source
var (

	// APIVersion is the version string that is written in API responses
	APIVersion = version.String
)

Functions

func DatasetRefFromCtx added in v0.1.2

func DatasetRefFromCtx(ctx context.Context) reporef.DatasetRef

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

func DatasetRefFromPath added in v0.1.2

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

DatasetRefFromPath parses a path and returns a datasetRef

func DatasetRefFromReq added in v0.1.2

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

DatasetRefFromReq examines the path element of a request URL to

func HTTPPathToQriPath added in v0.1.2

func HTTPPathToQriPath(path string) string

HTTPPathToQriPath converts a http path to a qri path

func HTTPSRedirect

func HTTPSRedirect(addr string)

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

func HealthCheckHandler added in v0.5.1

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

func NewServerRoutes(s Server) *http.ServeMux

NewServerRoutes returns a Muxer that has all API routes

func StartServer

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

StartServer interprets info from config to start an API server

Types

type DataResponse added in v0.2.0

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 added in v0.1.2

type DatasetHandlers struct {
	lib.DatasetMethods

	ReadOnly bool
	// contains filtered or unexported fields
}

DatasetHandlers wraps a requests struct to interface with http.HandlerFunc

func NewDatasetHandlers added in v0.1.2

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

NewDatasetHandlers allocates a DatasetHandlers pointer

func (*DatasetHandlers) AddHandler added in v0.1.2

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

AddHandler is an endpoint for creating new datasets

func (*DatasetHandlers) BodyHandler added in v0.5.0

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

BodyHandler gets the contents of a dataset

func (*DatasetHandlers) DiffHandler added in v0.2.0

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

DiffHandler is a dataset single endpoint

func (*DatasetHandlers) GetHandler added in v0.1.2

func (h *DatasetHandlers) GetHandler(endpointPath string) http.HandlerFunc

GetHandler is a dataset single endpoint

func (*DatasetHandlers) ListHandler added in v0.1.2

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

ListHandler is a dataset list endpoint

func (*DatasetHandlers) PeerListHandler added in v0.1.2

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

PeerListHandler is a dataset list endpoint

func (*DatasetHandlers) RemoveHandler added in v0.1.2

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

RemoveHandler is a a dataset delete endpoint

func (*DatasetHandlers) RenameHandler added in v0.1.2

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

RenameHandler is the endpoint for renaming datasets

func (*DatasetHandlers) SaveHandler added in v0.1.2

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

SaveHandler is a dataset save/update endpoint

func (*DatasetHandlers) StatsHandler added in v0.9.2

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

StatsHandler gets stats about the dataset

func (*DatasetHandlers) UnpackHandler added in v0.5.6

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

UnpackHandler unpacks a zip file and sends it back as json

func (*DatasetHandlers) ZipDatasetHandler added in v0.1.2

func (h *DatasetHandlers) ZipDatasetHandler(endpointPath string) http.HandlerFunc

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

type DatasetLogItem added in v0.9.7

type DatasetLogItem = logbook.DatasetLogItem

DatasetLogItem aliases the type from logbook

type FSIHandlers added in v0.9.0

type FSIHandlers struct {
	lib.FSIMethods

	ReadOnly bool
	// contains filtered or unexported fields
}

FSIHandlers connects HTTP requests to the FSI subsystem

func NewFSIHandlers added in v0.9.0

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

NewFSIHandlers creates handlers that talk to qri's filesystem integration

func (*FSIHandlers) CheckoutHandler added in v0.9.0

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

CheckoutHandler invokes checkout via an API call

func (*FSIHandlers) InitHandler added in v0.9.0

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

InitHandler creates a new FSI-linked dataset

func (*FSIHandlers) RestoreHandler added in v0.9.0

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

RestoreHandler invokes restore via an API call

func (*FSIHandlers) StatusHandler added in v0.9.0

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

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

func (*FSIHandlers) WhatChangedHandler added in v0.9.7

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

WhatChangedHandler is the endpoint for showing what changed for a specific commit

func (*FSIHandlers) WriteHandler added in v0.9.0

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

WriteHandler writes input data to the local filesystem link

type LogHandlers added in v0.5.2

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

LogHandlers wraps a LogMethods with http.HandlerFuncs

func NewLogHandlers added in v0.5.2

func NewLogHandlers(inst *lib.Instance) *LogHandlers

NewLogHandlers allocates a LogHandlers pointer

func (*LogHandlers) LogHandler added in v0.5.2

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

LogHandler is the endpoint for dataset logs

type PeerHandlers added in v0.1.2

type PeerHandlers struct {
	lib.PeerMethods
	ReadOnly bool
}

PeerHandlers wraps a requests struct to interface with http.HandlerFunc

func NewPeerHandlers added in v0.1.2

func NewPeerHandlers(inst *lib.Instance, readOnly bool) *PeerHandlers

NewPeerHandlers allocates a PeerHandlers pointer

func (*PeerHandlers) ConnectToPeerHandler added in v0.2.0

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

ConnectToPeerHandler is the endpoint for explicitly connecting to a peer

func (*PeerHandlers) ConnectionsHandler added in v0.1.2

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

ConnectionsHandler is the endpoint for listing qri & IPFS connections

func (*PeerHandlers) PeerHandler added in v0.2.0

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

PeerHandler gets info on a single peer

func (*PeerHandlers) PeersHandler added in v0.1.2

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

PeersHandler is the endpoint for fetching peers

type ProfileHandlers added in v0.1.2

type ProfileHandlers struct {
	lib.ProfileMethods
	ReadOnly bool
}

ProfileHandlers wraps a requests struct to interface with http.HandlerFunc

func NewProfileHandlers added in v0.1.2

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

NewProfileHandlers allocates a ProfileHandlers pointer

func (*ProfileHandlers) PosterHandler added in v0.3.1

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

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

func (*ProfileHandlers) ProfileHandler added in v0.1.2

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

ProfileHandler is the endpoint for this peer's profile

func (*ProfileHandlers) ProfilePhotoHandler added in v0.3.1

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

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

type QriCtxKey added in v0.1.2

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 added in v0.9.0

type RegistryClientHandlers struct {
	*lib.RegistryClientMethods
	// contains filtered or unexported fields
}

RegistryClientHandlers wraps a requests struct to interface with http.HandlerFunc

func NewRegistryClientHandlers added in v0.9.0

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

NewRegistryClientHandlers allocates a RegistryClientHandlers pointer

func (*RegistryClientHandlers) CreateProfileHandler added in v0.9.0

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

CreateProfileHandler creates a profile, associating it with a private key

func (*RegistryClientHandlers) ProveProfileKeyHandler added in v0.9.0

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 added in v0.9.0

type RemoteClientHandlers struct {
	*lib.RemoteMethods
	// contains filtered or unexported fields
}

RemoteClientHandlers provides HTTP handlers for issuing requests to remotes

func NewRemoteClientHandlers added in v0.9.0

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

NewRemoteClientHandlers creates remote client Handlers from a qri instance

func (*RemoteClientHandlers) DatasetPreviewHandler added in v0.9.5

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

DatasetPreviewHandler fetches a dataset preview from the registry

func (*RemoteClientHandlers) FeedsHandler added in v0.9.5

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

FeedsHandler fetches an index of named feeds

func (*RemoteClientHandlers) PublishHandler added in v0.9.0

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 added in v0.7.3

type RemoteHandlers struct {
	*lib.RemoteMethods
	DsyncHandler   http.HandlerFunc
	RefsHandler    http.HandlerFunc
	LogsyncHandler http.HandlerFunc
}

RemoteHandlers wraps a request struct to interface with http.HandlerFunc

func NewRemoteHandlers added in v0.7.3

func NewRemoteHandlers(inst *lib.Instance) *RemoteHandlers

NewRemoteHandlers allocates a RemoteHandlers pointer

type RenderHandlers added in v0.5.1

type RenderHandlers struct {
	lib.RenderMethods
}

RenderHandlers wraps a requests struct to interface with http.HandlerFunc

func NewRenderHandlers added in v0.5.1

func NewRenderHandlers(inst *lib.Instance) *RenderHandlers

NewRenderHandlers allocates a RenderHandlers pointer

func (*RenderHandlers) RenderHandler added in v0.5.1

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

RenderHandler renders a given dataset ref

type RootHandler added in v0.1.2

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 added in v0.1.2

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

NewRootHandler creates a new RootHandler

func (*RootHandler) Handler added in v0.1.2

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

Handler is the only Handler func for the RootHandler struct

type SQLHandlers added in v0.9.7

type SQLHandlers struct {
	lib.SQLMethods
	ReadOnly bool
}

SQLHandlers connects HTTP requests to the FSI subsystem

func NewSQLHandlers added in v0.9.7

func NewSQLHandlers(inst *lib.Instance, readOnly bool) SQLHandlers

NewSQLHandlers creates handlers that talk to qri's filesystem integration

func (*SQLHandlers) QueryHandler added in v0.9.7

func (h *SQLHandlers) QueryHandler(routePrefix string) http.HandlerFunc

QueryHandler runs an SQL query over HTTP

type SearchHandlers added in v0.5.1

type SearchHandlers struct {
	lib.SearchMethods
}

SearchHandlers wraps a requests struct to interface with http.HandlerFunc

func NewSearchHandlers added in v0.5.1

func NewSearchHandlers(inst *lib.Instance) *SearchHandlers

NewSearchHandlers allocates a SearchHandlers pointer

func (*SearchHandlers) SearchHandler added in v0.5.1

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

SearchHandler is the endpoint for searching qri

type Server

type Server struct {
	*lib.Instance
}

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

func New

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

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

func (*Server) HandleIPFSPath

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

HandleIPFSPath responds to IPFS Hash requests with raw data

func (Server) HandleIPNSPath added in v0.2.0

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

HandleIPNSPath resolves an IPNS entry

func (Server) Serve

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

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

func (Server) ServeWebsocket added in v0.9.4

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

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

Jump to

Keyboard shortcuts

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