Documentation
¶
Overview ¶
Package api implements a JSON-API for interacting with a qri node
Index ¶
- Constants
- func DatasetRefFromCtx(ctx context.Context) repo.DatasetRef
- func DatasetRefFromPath(path string) (repo.DatasetRef, error)
- func DatasetRefFromReq(r *http.Request) (repo.DatasetRef, error)
- func HTTPPathToQriPath(path string) string
- func HTTPSRedirect(addr string)
- func HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func NewServerRoutes(s Server) *http.ServeMux
- func StartServer(c *config.API, s *http.Server) error
- type DataResponse
- type DatasetHandlers
- func (h *DatasetHandlers) AddHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) BodyHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) DiffHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) GetHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) ListHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) PeerListHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) PublishHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) RemoveHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) RenameHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) SaveHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) UnpackHandler(w http.ResponseWriter, r *http.Request)
- func (h *DatasetHandlers) ZipDatasetHandler(w http.ResponseWriter, r *http.Request)
- type LogHandlers
- type PeerHandlers
- func (h *PeerHandlers) ConnectToPeerHandler(w http.ResponseWriter, r *http.Request)
- func (h *PeerHandlers) ConnectionsHandler(w http.ResponseWriter, r *http.Request)
- func (h *PeerHandlers) PeerHandler(w http.ResponseWriter, r *http.Request)
- func (h *PeerHandlers) PeersHandler(w http.ResponseWriter, r *http.Request)
- type ProfileHandlers
- type QriCtxKey
- type RegistryHandlers
- type RemoteHandlers
- type RenameReqParams
- type RenderHandlers
- type RootHandler
- type SearchHandlers
- type Server
- func (s Server) FrontendHandler(prefix string) http.Handler
- func (s *Server) HandleIPFSPath(w http.ResponseWriter, r *http.Request)
- func (s Server) HandleIPNSPath(w http.ResponseWriter, r *http.Request)
- func (s Server) Serve(ctx context.Context) (err error)
- func (s Server) ServeRPC(ctx context.Context)
- func (s Server) ServeWebapp(ctx context.Context)
- func (s Server) WebappTemplateHandler(w http.ResponseWriter, r *http.Request)
- type UpdateHandlers
- func (h *UpdateHandlers) LogFileHandler(w http.ResponseWriter, r *http.Request)
- func (h *UpdateHandlers) LogsHandler(w http.ResponseWriter, r *http.Request)
- func (h UpdateHandlers) RunHandler(w http.ResponseWriter, r *http.Request)
- func (h UpdateHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request)
- func (h *UpdateHandlers) UpdatesHandler(w http.ResponseWriter, r *http.Request)
Constants ¶
const LocalHostIP = "127.0.0.1"
LocalHostIP is the IP address for localhost
Variables ¶
This section is empty.
Functions ¶
func DatasetRefFromCtx ¶ added in v0.1.2
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 ¶ added in v0.1.2
func DatasetRefFromPath(path string) (repo.DatasetRef, error)
DatasetRefFromPath parses a path and returns a datasetRef
func DatasetRefFromReq ¶ added in v0.1.2
func DatasetRefFromReq(r *http.Request) (repo.DatasetRef, error)
DatasetRefFromReq examines the path element of a request URL to
func HTTPPathToQriPath ¶ added in v0.1.2
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 ¶
NewServerRoutes returns a Muxer that has all API routes
func StartServer ¶
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
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.DatasetRequests
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(node *p2p.QriNode, 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(w http.ResponseWriter, r *http.Request)
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) PublishHandler ¶ added in v0.6.0
func (h *DatasetHandlers) PublishHandler(w http.ResponseWriter, r *http.Request)
PublishHandler works with dataset publicity
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) 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(w http.ResponseWriter, r *http.Request)
ZipDatasetHandler is the endpoint for getting a zip archive of a dataset
type LogHandlers ¶ added in v0.5.2
type LogHandlers struct {
lib.LogRequests
}
LogHandlers wraps a LogRequests with http.HandlerFuncs
func NewLogHandlers ¶ added in v0.5.2
func NewLogHandlers(n *p2p.QriNode) *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.PeerRequests
ReadOnly bool
}
PeerHandlers wraps a requests struct to interface with http.HandlerFunc
func NewPeerHandlers ¶ added in v0.1.2
func NewPeerHandlers(node *p2p.QriNode, 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 RegistryHandlers ¶ added in v0.5.1
type RegistryHandlers struct {
lib.RegistryRequests
// contains filtered or unexported fields
}
RegistryHandlers wraps a requests struct to interface with http.HandlerFunc
func NewRegistryHandlers ¶ added in v0.5.1
func NewRegistryHandlers(node *p2p.QriNode) *RegistryHandlers
NewRegistryHandlers allocates a RegistryHandlers pointer
func (*RegistryHandlers) RegistryDatasetHandler ¶ added in v0.6.1
func (h *RegistryHandlers) RegistryDatasetHandler(w http.ResponseWriter, r *http.Request)
RegistryDatasetHandler is the endpoint to get a dataset summary from the registry
func (*RegistryHandlers) RegistryDatasetsHandler ¶ added in v0.6.1
func (h *RegistryHandlers) RegistryDatasetsHandler(w http.ResponseWriter, r *http.Request)
RegistryDatasetsHandler is the endpoint to get the list of dataset summaries available on the registry
func (*RegistryHandlers) RegistryHandler ¶ added in v0.5.1
func (h *RegistryHandlers) RegistryHandler(w http.ResponseWriter, r *http.Request)
RegistryHandler is the endpoint to call to the registry
type RemoteHandlers ¶ added in v0.7.3
type RemoteHandlers struct {
*lib.RemoteRequests
}
RemoteHandlers wraps a request struct to interface with http.HandlerFunc
func NewRemoteHandlers ¶ added in v0.7.3
NewRemoteHandlers allocates a RemoteHandlers pointer
func (*RemoteHandlers) CompleteHandler ¶ added in v0.7.3
func (h *RemoteHandlers) CompleteHandler(w http.ResponseWriter, r *http.Request)
CompleteHandler is the endpoint for remotes when they complete the dsync process
func (*RemoteHandlers) ReceiveHandler ¶ added in v0.7.3
func (h *RemoteHandlers) ReceiveHandler(w http.ResponseWriter, r *http.Request)
ReceiveHandler is the endpoint for remotes to receive daginfo
type RenameReqParams ¶ added in v0.1.2
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 ¶ added in v0.5.1
type RenderHandlers struct {
lib.RenderRequests
// contains filtered or unexported fields
}
RenderHandlers wraps a requests struct to interface with http.HandlerFunc
func NewRenderHandlers ¶ added in v0.5.1
func NewRenderHandlers(r repo.Repo) *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 SearchHandlers ¶ added in v0.5.1
type SearchHandlers struct {
lib.SearchRequests
}
SearchHandlers wraps a requests struct to interface with http.HandlerFunc
func NewSearchHandlers ¶ added in v0.5.1
func NewSearchHandlers(node *p2p.QriNode) *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 ¶
Server wraps a qri p2p node, providing traditional access via http Create one with New, start it up with Serve
func (Server) FrontendHandler ¶ added in v0.6.1
FrontendHandler resolves the current webapp hash, (fetching the compiled frontend in the process) and serves it up as a traditional HTTP endpoint, transparently redirecting requests for [prefix]/foo.js to [CAFS Hash]/foo.js prefix is the path prefix that should be stripped from the request URL.Path
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) ServeWebapp ¶ added in v0.2.0
ServeWebapp launches a webapp server on s.cfg.Webapp.Port
func (Server) WebappTemplateHandler ¶ added in v0.6.1
func (s Server) WebappTemplateHandler(w http.ResponseWriter, r *http.Request)
WebappTemplateHandler renders the home page
type UpdateHandlers ¶ added in v0.8.0
type UpdateHandlers struct {
*lib.UpdateMethods
ReadOnly bool
}
UpdateHandlers wraps lib.UpdateMethods, adding HTTP JSON API handles
func (*UpdateHandlers) LogFileHandler ¶ added in v0.8.0
func (h *UpdateHandlers) LogFileHandler(w http.ResponseWriter, r *http.Request)
LogFileHandler fetches log output file data
func (*UpdateHandlers) LogsHandler ¶ added in v0.8.0
func (h *UpdateHandlers) LogsHandler(w http.ResponseWriter, r *http.Request)
LogsHandler shows the log of previously run updates
func (UpdateHandlers) RunHandler ¶ added in v0.8.0
func (h UpdateHandlers) RunHandler(w http.ResponseWriter, r *http.Request)
RunHandler brings a dataset to the latest version
func (UpdateHandlers) ServiceHandler ¶ added in v0.8.0
func (h UpdateHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request)
ServiceHandler configures & reports on the update daemon
func (*UpdateHandlers) UpdatesHandler ¶ added in v0.8.0
func (h *UpdateHandlers) UpdatesHandler(w http.ResponseWriter, r *http.Request)
UpdatesHandler brings a dataset to the latest version