client

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Api = 2
View Source
var Webpage = 1
View Source
var WebpageApi = 3 // without "x-dbd-xsrf"

Functions

This section is empty.

Types

type Client

type Client interface {
	Load(ctx context.Context) error
	Call(ctx context.Context, api string, targetType int) (*http.Response, error)
	Send(ctx context.Context, req *http.Request, targetType int) (*http.Response, error)
	Endpoint(api string) (*url.URL, error)
	NewPostRequest(api string, params url.Values) (*http.Request, error)
}

type ClientLogger

type ClientLogger struct {
	Base Client
	Dir  string
}

func WrapLogger

func WrapLogger(client Client, dir string) *ClientLogger

func (*ClientLogger) Call

func (client *ClientLogger) Call(ctx context.Context, api string, targetType int) (*http.Response, error)

func (*ClientLogger) Endpoint

func (client *ClientLogger) Endpoint(api string) (*url.URL, error)

func (*ClientLogger) Load

func (client *ClientLogger) Load(ctx context.Context) error

func (*ClientLogger) NewPostRequest

func (client *ClientLogger) NewPostRequest(api string, params url.Values) (*http.Request, error)

func (*ClientLogger) Send

func (client *ClientLogger) Send(ctx context.Context, req *http.Request, targetType int) (*http.Response, error)

type DatabaseStore

type DatabaseStore struct {
	DB        *sqlx.DB
	SessionId string
	Cookies   []*http.Cookie
}

func NewDatabaseStore

func NewDatabaseStore(db *sqlx.DB) *DatabaseStore

func (*DatabaseStore) GetCookies

func (store *DatabaseStore) GetCookies() []*http.Cookie

func (*DatabaseStore) RestoreCookies

func (store *DatabaseStore) RestoreCookies(ctx context.Context) error

func (*DatabaseStore) Save

func (store *DatabaseStore) Save(ctx context.Context) error

func (*DatabaseStore) SetCookies

func (store *DatabaseStore) SetCookies(cookies []*http.Cookie)

type HttpClient

type HttpClient struct {
	Http   *http.Client
	Base   *url.URL
	Status *Status
	Store  Store
}

func NewClient

func NewClient(store Store) (*HttpClient, error)

func (*HttpClient) Call

func (client *HttpClient) Call(ctx context.Context, api string, targetType int) (*http.Response, error)

func (*HttpClient) Endpoint

func (client *HttpClient) Endpoint(api string) (*url.URL, error)

func (*HttpClient) Load

func (client *HttpClient) Load(ctx context.Context) error

func (*HttpClient) NewPostRequest

func (client *HttpClient) NewPostRequest(api string, params url.Values) (*http.Request, error)

func (*HttpClient) Send

func (client *HttpClient) Send(ctx context.Context, req *http.Request, targetType int) (*http.Response, error)

type MockClient

type MockClient struct {
	Base *url.URL
	// contains filtered or unexported fields
}

func NewMockClient

func NewMockClient() *MockClient

func (*MockClient) AppendResponse

func (client *MockClient) AppendResponse(res *http.Response)

func (*MockClient) Call

func (client *MockClient) Call(ctx context.Context, api string, targetType int) (*http.Response, error)

func (*MockClient) Endpoint

func (client *MockClient) Endpoint(api string) (*url.URL, error)

func (*MockClient) Load

func (client *MockClient) Load(ctx context.Context) error

func (*MockClient) MockRemaining

func (client *MockClient) MockRemaining() int

func (*MockClient) NewPostRequest

func (client *MockClient) NewPostRequest(api string, params url.Values) (*http.Request, error)

func (*MockClient) Send

func (client *MockClient) Send(ctx context.Context, req *http.Request, targetType int) (*http.Response, error)

type Status

type Status struct {
	Logged bool
}

func NewStatus

func NewStatus() *Status

type Store

type Store interface {
	RestoreCookies(ctx context.Context) error
	GetCookies() []*http.Cookie
	SetCookies(cookies []*http.Cookie)
	Save(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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