request

package
v0.0.0-...-1059341 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequest

func NewRequest(ctx context.Context, url, namespace string, header http.Header) *request

func PostJsonRPC

func PostJsonRPC(client *http.Client, url string, in Request, requestHeader http.Header) ([]byte, error)

Types

type Builder

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

Builder is an IPFS commands request builder.

func NewBuilder

func NewBuilder(c *http.Client, baseApi, namespace string, requestHeader http.Header) *Builder

func (*Builder) Body

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

Body sets the request body to the given reader.

func (*Builder) BodyBytes

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

BodyBytes sets the request body to the given buffer.

func (*Builder) BodyString

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

BodyString sets the request body to the given string.

func (*Builder) Exec

func (r *Builder) Exec(ctx context.Context, res interface{}) error

Exec sends the request a request and decodes the response.

func (*Builder) Get

func (r *Builder) Get(ctx context.Context) (*response, error)

Get sends the get request and return the response.

func (*Builder) Head

func (r *Builder) Head(ctx context.Context) (http.Header, error)

Head sends the head request and return the response.

func (*Builder) Header

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

Header sets the given header.

func (*Builder) Option

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

Option sets the given config.

func (*Builder) Post

func (r *Builder) Post(ctx context.Context) (*response, error)

Post sends the post request and return the response.

type Error

type Error struct {
	Namespace string
	Message   string
	Code      int
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int

type Request

type Request struct {
	Jsonrpc string            `json:"jsonrpc"`
	ID      interface{}       `json:"id,omitempty"`
	Method  string            `json:"method"`
	Params  json.RawMessage   `json:"params"`
	Meta    map[string]string `json:"meta,omitempty"`
}

Request defines a JSON RPC request from the spec http://www.jsonrpc.org/specification#request_object

type Response

type Response struct {
	Jsonrpc string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	ID      interface{} `json:"id"`
	Error   *respError  `json:"error,omitempty"`
}

Response defines a JSON RPC response from the spec http://www.jsonrpc.org/specification#response_object

Jump to

Keyboard shortcuts

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