rest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 18 Imported by: 0

Documentation

Overview

Package rest implements an IPFS Cluster API component. It provides a REST-ish API to interact with Cluster.

The implented API is based on the common.API component (refer to module description there). The only thing this module does is to provide route handling for the otherwise common API component.

Index

Constants

View Source
const (
	DefaultReadTimeout       = 0
	DefaultReadHeaderTimeout = 5 * time.Second
	DefaultWriteTimeout      = 0
	DefaultIdleTimeout       = 120 * time.Second
	DefaultMaxHeaderBytes    = minMaxHeaderBytes
)

Default values for Config.

Variables

View Source
var (
	// DefaultHTTPListenAddrs contains default listen addresses for the HTTP API.
	DefaultHTTPListenAddrs = []string{"/ip4/127.0.0.1/tcp/9094"}
	DefaultHeaders         = map[string][]string{}
)

Default values for Config.

View Source
var (
	DefaultCORSAllowedOrigins = []string{"*"}
	DefaultCORSAllowedMethods = []string{
		http.MethodGet,
	}
	// rs/cors this will set sensible defaults when empty:
	// {"Origin", "Accept", "Content-Type", "X-Requested-With"}
	DefaultCORSAllowedHeaders = []string{}
	DefaultCORSExposedHeaders = []string{
		"Content-Type",
		"X-Stream-Output",
		"X-Chunked-Output",
		"X-Content-Length",
	}
	DefaultCORSAllowCredentials = true
	DefaultCORSMaxAge           time.Duration // 0. Means always.
)

CORS defaults.

Functions

This section is empty.

Types

type API

type API struct {
	*common.API
	// contains filtered or unexported fields
}

API implements the REST API Component. It embeds a common.API.

func NewAPI

func NewAPI(ctx context.Context, cfg *Config) (*API, error)

NewAPI creates a new REST API component.

func NewAPIWithHost added in v0.3.5

func NewAPIWithHost(ctx context.Context, cfg *Config, h host.Host) (*API, error)

NewAPIWithHost creates a new REST API component using the given libp2p Host.

type Config

type Config struct {
	common.Config
}

Config fully implements the config.ComponentConfig interface. Use NewConfig() to instantiate. Config embeds a common.Config object.

func NewConfig added in v0.14.2

func NewConfig() *Config

NewConfig creates a Config object setting the necessary meta-fields in the common.Config embedded object.

func (*Config) ConfigKey

func (cfg *Config) ConfigKey() string

ConfigKey returns a human-friendly identifier for this type of Config.

func (*Config) Default

func (cfg *Config) Default() error

Default initializes this Config with working values.

Directories

Path Synopsis
Package client provides a Go Client for the IPFS Cluster API provided by the "api/rest" component.
Package client provides a Go Client for the IPFS Cluster API provided by the "api/rest" component.

Jump to

Keyboard shortcuts

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