client

package
v0.0.0-...-239b6c0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost = "https://www.myminifactory.com/"
)
View Source
const (
	DirectoryMode fs.FileMode = 0755
)
View Source
const (
	MaxLoginAttempts = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoLogin

type AutoLogin struct {
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

func (*AutoLogin) IsLoginRedirect

func (m *AutoLogin) IsLoginRedirect(resp *http.Response) bool

func (*AutoLogin) NewClient

func (m *AutoLogin) NewClient() *http.Client

func (*AutoLogin) RoundTrip

func (m *AutoLogin) RoundTrip(req *http.Request) (*http.Response, error)

type Client

type Client struct {
	*resty.Client

	Credentials  mmf.Credentials
	TraceEnabled bool
}

func New

func New(cred mmf.Credentials) *Client

func NewWithClient

func NewWithClient(cred mmf.Credentials, hc *http.Client) *Client

func NewWithOptions

func NewWithOptions(options ...ClientOption) (*Client, error)

func NewWithTransport

func NewWithTransport(cred mmf.Credentials, transport http.RoundTripper) *Client

func (*Client) Init

func (c *Client) Init(cred mmf.Credentials, rc *resty.Client) *Client

func (*Client) J

func (c *Client) J(referer string, args ...interface{}) *resty.Request

func (*Client) Pages

func (c *Client) Pages(n, total int) *Pagination

func (*Client) PagesN

func (c *Client) PagesN(n int, count json.Number) *Pagination

func (*Client) R

func (c *Client) R(referer string, args ...interface{}) *resty.Request

func (*Client) SetTransport

func (c *Client) SetTransport(next http.RoundTripper) *Client

type ClientOption

type ClientOption interface {
	Apply(c *Client) error
}

func WithCookieJar

func WithCookieJar(jar http.CookieJar) ClientOption

func WithCredentials

func WithCredentials(cred mmf.Credentials) ClientOption

func WithTransport

func WithTransport(transport http.RoundTripper) ClientOption

type ClientOptionFunc

type ClientOptionFunc func(*Client) error

func (ClientOptionFunc) Apply

func (f ClientOptionFunc) Apply(c *Client) error

type LoginForm

type LoginForm struct {
	Action  string
	EncType string
	Method  string
	Referer string
	Fields  map[string]string
}

func (*LoginForm) Request

func (form *LoginForm) Request(c *resty.Client) (*resty.Response, error)

type LoginParseState

type LoginParseState func(z *html.Tokenizer, form *LoginForm) (LoginParseState, error)

type Pagination

type Pagination struct {
	Size  int
	Total int
}

func Pages

func Pages(n, total int) *Pagination

func PagesN

func PagesN(n int, count json.Number) *Pagination

func (*Pagination) Next

func (p *Pagination) Next(prev int) (int, int, bool)

type Request

type Request struct {
	*resty.Request

	Client  *Client
	Handler ResponseHandler
	Output  *os.File
}

func (*Request) Execute

func (req *Request) Execute() error

func (*Request) Get

func (req *Request) Get() (*resty.Response, error)

type RequestOptions

type RequestOptions struct {
	Accept          string
	Referer         string
	Path            string
	Query           url.Values
	Method          string
	Result          interface{}
	OutputDirectory string
	Handler         ResponseHandler
}

func (RequestOptions) Clone

func (opt RequestOptions) Clone() RequestOptions

func (RequestOptions) New

func (opt RequestOptions) New(c *Client, ctx context.Context) *Request

func (*RequestOptions) Setf

func (opt *RequestOptions) Setf(k string, v string, args ...interface{})

type ResponseHandler

type ResponseHandler func(c *Client, req *Request, resp *resty.Response) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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