corehttp

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 58 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const APIPath = "/api/v0"

APIPath is the path at which the API is mounted.

View Source
const WebUIPath = "/dms3/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i" // v2.11.4

TODO: move to DMS3NS

Variables

View Source
var WebUIOption = RedirectOption("webui", WebUIPath)
View Source
var WebUIPaths = []string{
	WebUIPath,
	"/dms3/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4",
	"/dms3/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m",
	"/dms3/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e",
	"/dms3/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu",
	"/dms3/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq",
	"/dms3/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4",
	"/dms3/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i",
	"/dms3/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq",
	"/dms3/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub",
	"/dms3/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ",
	"/dms3/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA",
	"/dms3/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e",
	"/dms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1dePTSjkTfGVwTh55ZcsJxrCSnk",
	"/dms3/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m",
	"/dms3/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK",
	"/dms3/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW",
	"/dms3/Qmexhq2sBHnXQbvyP2GfUdbnY7HCagH2Mw5vUNSBn2nxip",
}

this is a list of all past webUI paths.

Functions

func ListenAndServe

func ListenAndServe(n *core.Dms3Node, 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".

func Serve

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

Serve accepts incoming HTTP connections on the listener and pass them to ServeOption handlers.

Types

type Dms3NodeCollector

type Dms3NodeCollector struct {
	Node *core.Dms3Node
}

func (Dms3NodeCollector) Collect

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

func (Dms3NodeCollector) Describe

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

func (Dms3NodeCollector) PeersTotalValues

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

type GatewayConfig

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

type ServeOption

type ServeOption func(*core.Dms3Node, 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

func CheckVersionOption() ServeOption

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

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 GatewayOption

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

func HostnameOption

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 MetricsOpenCensusCollectionOption

func MetricsOpenCensusCollectionOption() ServeOption

This adds collection of OpenCensus 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

func P2PProxyOption() ServeOption

P2PProxyOption is an endpoint for proxying a HTTP request to another dms3 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