Documentation ¶
Overview ¶
Package corehttp provides utilities for the webui, gateways, and other high-level HTTP interfaces to IPFS.
Index ¶
- Constants
- Variables
- func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...ServeOption) error
- func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error
- type GatewayConfig
- type IpfsNodeCollector
- type ReedSolomonDirectory
- type ServeOption
- func CheckVersionOption() ServeOption
- func CommandsOption(cctx oldcmds.Context) ServeOption
- func CommandsROOption(cctx oldcmds.Context) ServeOption
- func CommandsRemoteOption(cctx oldcmds.Context) ServeOption
- func GatewayOption(writable bool, paths ...string) ServeOption
- func HostnameOption() ServeOption
- func LogOption() ServeOption
- func MetricsCollectionOption(handlerName string) ServeOption
- func MetricsScrapingOption(path string) ServeOption
- func MutexFractionOption(path string) ServeOption
- func P2PProxyOption() ServeOption
- func RedirectOption(path string, redirect string) ServeOption
- func StaticOption(path, dir string) ServeOption
- func VersionOption() ServeOption
Constants ¶
const APIPath = "/api/" + shell.API_VERSION
APIPath is the path at which the API is mounted.
const (
GatewayReedSolomonDirectoryCacheCapacity = 10
)
const HostUIDir = "/hostui"
const WebUIPath = "/btfs/QmVc2xjpt1xbBDu98QdDnPNS7nwyAgMvPbNpegJ9YyeLTd"
TODO: move to BTNS
Variables ¶
var HostUIOption = StaticOption("hostui", HostUIDir)
var WebUIOption = RedirectOption("webui", WebUIPath)
var WebUIPaths = []string{ WebUIPath, }
this is a list of all past webUI paths.
Functions ¶
func ListenAndServe ¶
func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...ServeOption) error
ListenAndServe runs an HTTP server listening at |listeningMultiAddr| with the given serve options. The address must be provided in multiaddr format.
TODO intelligently parse address strings in other formats so long as they unambiguously map to a valid multiaddr. e.g. for convenience, ":8080" should map to "/ip4/0.0.0.0/tcp/8080".
Types ¶
type GatewayConfig ¶
type IpfsNodeCollector ¶
func (IpfsNodeCollector) Collect ¶
func (c IpfsNodeCollector) Collect(ch chan<- prometheus.Metric)
func (IpfsNodeCollector) Describe ¶
func (_ IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc)
func (IpfsNodeCollector) PeersTotalValues ¶
func (c IpfsNodeCollector) PeersTotalValues() map[string]float64
type ReedSolomonDirectory ¶ added in v1.5.0
type ReedSolomonDirectory struct {
// contains filtered or unexported fields
}
func (ReedSolomonDirectory) Size ¶ added in v1.5.0
func (d ReedSolomonDirectory) Size() uint64
type ServeOption ¶
ServeOption registers any HTTP handlers it provides on the given mux. It returns the mux to expose to future options, which may be a new mux if it is interested in mediating requests to future options, or the same mux initially passed in if not.
func CheckVersionOption ¶
func CheckVersionOption() ServeOption
CheckVersionOption returns a ServeOption that checks whether the client btfs version matches. Does nothing when the user agent string does not contain `/go-btfs/`
func CommandsOption ¶
func CommandsOption(cctx oldcmds.Context) ServeOption
CommandsOption constructs a ServerOption for hooking the commands into the HTTP server. It will NOT allow GET requests.
func CommandsROOption ¶
func CommandsROOption(cctx oldcmds.Context) ServeOption
CommandsROOption constructs a ServerOption for hooking the read-only commands into the HTTP server. It will allow GET requests.
func CommandsRemoteOption ¶ added in v1.5.0
func CommandsRemoteOption(cctx oldcmds.Context) ServeOption
CommandsRemoteOption constructs a ServerOption for hooking the public-facing, remote commands into the HTTP server.
func GatewayOption ¶
func GatewayOption(writable bool, paths ...string) ServeOption
func HostnameOption ¶ added in v1.5.0
func HostnameOption() ServeOption
HostnameOption rewrites an incoming request based on the Host header.
func LogOption ¶
func LogOption() ServeOption
func MetricsCollectionOption ¶
func MetricsCollectionOption(handlerName string) ServeOption
This adds collection of net/http-related metrics
func MetricsScrapingOption ¶
func MetricsScrapingOption(path string) ServeOption
This adds the scraping endpoint which Prometheus uses to fetch metrics.
func MutexFractionOption ¶
func MutexFractionOption(path string) ServeOption
MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP using POST request with parameter 'fraction'.
func P2PProxyOption ¶ added in v1.5.0
func P2PProxyOption() ServeOption
P2PProxyOption is an endpoint for proxying a HTTP request to another btfs peer
func RedirectOption ¶
func RedirectOption(path string, redirect string) ServeOption
func StaticOption ¶ added in v1.5.0
func StaticOption(path, dir string) ServeOption
func VersionOption ¶
func VersionOption() ServeOption