restclient

package
v0.0.0-...-37f3e00 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2016 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides an interface to restfulbrot over the web, using a user-defined web interface. This allows inclusion of this stock code within static archives for other platforms, or gopherjs for javascript.

func New

func New(config Config) *Client

func (*Client) Getimag

func (web *Client) Getimag(url string) (io.Reader, error)

func (*Client) Getrq

func (web *Client) Getrq(url string) (*protocol.RQGetResp, error)

func (*Client) Newrq

func (web *Client) Newrq(url string, renreq *protocol.RenderRequest) (*protocol.RQNewResp, error)

func (*Client) RenderCycle

func (web *Client) RenderCycle(url string, renreq *protocol.RenderRequest) (*RenderResult, error)

func (*Client) Rqzoom

func (web *Client) Rqzoom(rqurl string, renreq *protocol.RenderRequest) (*protocol.RQNewResp, error)

func (*Client) Url

func (web *Client) Url(path string) string

type Config

type Config struct {
	Addr     string
	Port     uint
	Prefix   string
	Ticktime uint
	Debug    bool
	Http     HttpClient
}

type HttpClient

type HttpClient interface {
	Get(string) (HttpResponse, error)
	Post(string, string, io.Reader) (HttpResponse, error)
}

type HttpRequest

type HttpRequest struct {
	Method string
	Url    string
	Ctype  string // TODO use struct tag
	Body   io.Reader
}

type HttpResponse

type HttpResponse interface {
	GetBody() io.ReadCloser
	GetStatusCode() int
	GetStatus() string
	GetHeader() map[string][]string
	Write(io.Writer) error
}

type RenderResult

type RenderResult struct {
	Image  io.Reader
	Status protocol.RQGetResp
}

type RestIO

type RestIO struct {
	Request  HttpRequest
	Response chan<- WebResult
}

type UserControl

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

UserControl is loosely coupled request/response mechanism

func NewUserControl

func NewUserControl(timeout uint) *UserControl

func (*UserControl) Comms

func (uc *UserControl) Comms() <-chan RestIO

Communicate with the restclient library asynchronously using Comms()

func (*UserControl) Get

func (uc *UserControl) Get(url string) (HttpResponse, error)

func (*UserControl) Post

func (uc *UserControl) Post(url string, ctype string, body io.Reader) (HttpResponse, error)

type WebResult

type WebResult struct {
	Response HttpResponse
	Error    error
}

Jump to

Keyboard shortcuts

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