soter

package
v0.0.0-...-149e0e5 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

package soter implements a remote API interface for a running ipfs daemon

Index

Constants

View Source
const (
	DefaultPathName = ".ipfs"
	DefaultPathRoot = "~/" + DefaultPathName
	DefaultApiFile  = "api"
	EnvDir          = "IPFS_PATH"
)
View Source
const (
	TRaw = iota
	TDirectory
	TFile
	TMetadata
	TSymlink
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Command string
	Message string
	Code    int
}

func (*Error) Error

func (e *Error) Error() string

type Request

type Request struct {
	Ctx     context.Context
	ApiBase string
	Command string
	Args    []string
	Opts    map[string]string
	Body    io.Reader
	Headers map[string]string
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(ctx context.Context, url, command string, args ...string) *Request

func (*Request) Get

func (r *Request) Get(c *http.Client) (string, error)

func (*Request) Send

func (r *Request) Send(c *http.Client) (*Response, error)

type RequestBuilder

type RequestBuilder struct {
	// contains filtered or unexported fields
}

RequestBuilder is an IPFS commands request builder.

func (*RequestBuilder) Arguments

func (r *RequestBuilder) Arguments(args ...string) *RequestBuilder

Arguments adds the arguments to the args.

func (*RequestBuilder) Body

func (r *RequestBuilder) Body(body io.Reader) *RequestBuilder

Body sets the request body to the given reader.

func (*RequestBuilder) BodyBytes

func (r *RequestBuilder) BodyBytes(body []byte) *RequestBuilder

BodyBytes sets the request body to the given buffer.

func (*RequestBuilder) BodyString

func (r *RequestBuilder) BodyString(body string) *RequestBuilder

BodyString sets the request body to the given string.

func (*RequestBuilder) ExecGet

func (r *RequestBuilder) ExecGet(ctx context.Context, res interface{}) error

Exec sends the request a request and decodes the response.

func (*RequestBuilder) ExecPost

func (r *RequestBuilder) ExecPost(ctx context.Context, res interface{}) error

Exec sends the request a request and decodes the response.

func (*RequestBuilder) Get

func (r *RequestBuilder) Get(ctx context.Context) (*Response, error)

Send sends the request and return the response.

func (*RequestBuilder) Header

func (r *RequestBuilder) Header(name, value string) *RequestBuilder

Header sets the given header.

func (*RequestBuilder) Option

func (r *RequestBuilder) Option(key string, value interface{}) *RequestBuilder

Option sets the given option.

func (*RequestBuilder) Send

func (r *RequestBuilder) Send(ctx context.Context) (*Response, error)

Send sends the request and return the response.

type Response

type Response struct {
	Output io.ReadCloser
	Error  *Error
}

func (*Response) Close

func (r *Response) Close() error

func (*Response) Decode

func (r *Response) Decode(dec interface{}) error

type Soter

type Soter struct {
	// contains filtered or unexported fields
}

func NewSoter

func NewSoter(url string) *Soter

func NewSoterWithClient

func NewSoterWithClient(url string, useraddr string, private string, c *gohttp.Client) *Soter

func (*Soter) Cat

func (s *Soter) Cat(path string) (io.ReadCloser, error)

Cat the content at the given path. Callers need to drain and close the returned reader after usage.

func (*Soter) List

func (s *Soter) List(path string) ([]*LsLink, error)

List entries at the given path

func (*Soter) QueryUserBalance

func (s *Soter) QueryUserBalance() (result string, err error)

func (*Soter) Request

func (s *Soter) Request(command string, args ...string) *RequestBuilder

func (*Soter) SetTimeout

func (s *Soter) SetTimeout(d time.Duration)

Jump to

Keyboard shortcuts

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