Version: v0.3.7 Latest Latest

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

Go to latest
Published: Aug 2, 2015 License: MIT Imports: 33 Imported by: 0



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



View Source
const WebUIPath = "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6"

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 BlockList

type BlockList struct {
	Decider Decider
	// contains filtered or unexported fields

func (*BlockList) SetDecider

func (b *BlockList) SetDecider(d Decider)

SetDecider atomically swaps the blocklist's decider. This method is thread-safe.

func (*BlockList) ShouldAllow

func (b *BlockList) ShouldAllow(s string) bool

func (*BlockList) ShouldBlock

func (b *BlockList) ShouldBlock(s string) bool

type Decider

type Decider func(string) bool

Decider decides whether to Allow string

type Gateway

type Gateway struct {
	Config GatewayConfig

Gateway should be instantiated using NewGateway

func NewGateway

func NewGateway(conf GatewayConfig) *Gateway

func (*Gateway) ServeOption

func (g *Gateway) ServeOption() ServeOption

type GatewayConfig

type GatewayConfig struct {
	Headers   map[string][]string
	BlockList *BlockList
	Writable  bool

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 CommandsOption

func CommandsOption(cctx commands.Context) ServeOption

func GatewayOption

func GatewayOption(writable bool) 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 PrometheusOption added in v0.3.6

func PrometheusOption(path string) ServeOption

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