publish

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const FileFieldName = "file"

FileFieldName refers to the POST field containing file upload

View Source
const JSONRPCFieldName = "json_payload"

JSONRPCFieldName is a name of the POST field containing JSONRPC request accompanying the uploaded file

Variables

View Source
var ErrUnauthorized = Error{/* contains filtered or unexported fields */}

Functions

func CreatePublishRequest added in v0.8.2

func CreatePublishRequest(t *testing.T, data []byte) *http.Request

CreatePublishRequest creates and returns a HTTP request providing data for the publishing endpoint.

Types

type Error

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

func NewAuthError

func NewAuthError(err error) Error

func NewInternalError

func NewInternalError(err error) Error

func (Error) AsBytes

func (e Error) AsBytes() []byte

func (Error) AsRPCResponse

func (e Error) AsRPCResponse() *jsonrpc.RPCResponse

func (Error) Code

func (e Error) Code() int

func (Error) Message

func (e Error) Message() string

type LbrynetPublisher

type LbrynetPublisher struct {
	*proxy.ProxyService
}

LbrynetPublisher is an implementation of SDK publisher.

func (*LbrynetPublisher) Publish

func (p *LbrynetPublisher) Publish(filePath, walletID string, rawQuery []byte) []byte

Publish takes a file path, account ID and client JSON-RPC query, patches the query and sends it to the SDK for processing. Resulting response is then returned back as a slice of bytes.

type Publisher

type Publisher interface {
	Publish(string, string, []byte) []byte
}

Publisher is responsible for sending data to lbrynet and should take file path, account ID and client query as a slice of bytes.

type UploadHandler

type UploadHandler struct {
	Publisher  Publisher
	UploadPath string
}

UploadHandler glues HTTP uploads to the Publisher.

func NewUploadHandler

func NewUploadHandler(opts UploadOpts) (*UploadHandler, error)

NewUploadHandler returns a HTTP upload handler object.

func (UploadHandler) CanHandle added in v0.8.2

func (h UploadHandler) CanHandle(r *http.Request, _ *mux.RouteMatch) bool

CanHandle checks if http.Request contains POSTed data in an accepted format. Supposed to be used in gorilla mux router MatcherFunc.

func (UploadHandler) Handle

Handle is where HTTP upload is handled and passed on to Publisher. It should be wrapped with users.Authenticator.Wrap before it can be used in a mux.Router.

type UploadOpts added in v0.8.2

type UploadOpts struct {
	Path         string
	Publisher    Publisher
	ProxyService *proxy.ProxyService
}

Jump to

Keyboard shortcuts

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