Version: v0.4.19 Latest Latest

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

Go to latest
Published: Mar 1, 2019 License: MIT Imports: 55 Imported by: 0



Package corehttp provides utilities for the webui, gateways, and other high-level HTTP interfaces to IPFS.



View Source
const APIPath = "/api/v0"

APIPath is the path at which the API is mounted.

View Source
const WebUIPath = "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ"

TODO: move to IPNS


View Source
var WebUIOption = RedirectOption("webui", WebUIPath)
View Source
var WebUIPaths = []string{

this is a list of all past webUI paths.


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/".

func Serve added in v0.3.5

func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error


type GatewayConfig

type GatewayConfig struct {
	Headers      map[string][]string
	Writable     bool
	PathPrefixes []string

type IpfsNodeCollector added in v0.4.1

type IpfsNodeCollector struct {
	Node *core.IpfsNode

func (IpfsNodeCollector) Collect added in v0.4.1

func (c IpfsNodeCollector) Collect(ch chan<- prometheus.Metric)

func (IpfsNodeCollector) Describe added in v0.4.1

func (_ IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc)

func (IpfsNodeCollector) PeersTotalValues added in v0.4.3

func (c IpfsNodeCollector) PeersTotalValues() map[string]float64

type ServeOption

type ServeOption func(*core.IpfsNode, net.Listener, *http.ServeMux) (*http.ServeMux, error)

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

func CheckVersionOption() ServeOption

CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/`

func CommandsOption

func CommandsOption(cctx oldcmds.Context) ServeOption

CommandsOption constructs a ServerOption for hooking the commands into the HTTP server.

func CommandsROOption added in v0.3.8

func CommandsROOption(cctx oldcmds.Context) ServeOption

CommandsROOption constructs a ServerOption for hooking the read-only commands into the HTTP server.

func GatewayOption

func GatewayOption(writable bool, paths ...string) ServeOption

func IPNSHostnameOption

func IPNSHostnameOption() ServeOption

IPNSHostnameOption rewrites an incoming request if its Host: header contains an IPNS name. The rewritten request points at the resolved name on the gateway handler.

func LogOption added in v0.3.6

func LogOption() ServeOption

func MetricsCollectionOption added in v0.4.1

func MetricsCollectionOption(handlerName string) ServeOption

This adds collection of net/http-related metrics

func MetricsScrapingOption added in v0.4.1

func MetricsScrapingOption(path string) ServeOption

This adds the scraping endpoint which Prometheus uses to fetch metrics.

func MutexFractionOption added in v0.4.18

func MutexFractionOption(path string) ServeOption

MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP using POST request with parameter 'fraction'.

func ProxyOption added in v0.4.19

func ProxyOption() ServeOption

ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer

func RedirectOption

func RedirectOption(path string, redirect string) ServeOption

func VersionOption

func VersionOption() ServeOption

Jump to

Keyboard shortcuts

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