util

package
v0.0.0-...-d6f4979 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEaURI

func BuildEaURI(resource string) string

func CookieFromRawCookie

func CookieFromRawCookie(rawCookie string) *http.Cookie

func Find

func Find(slice []string, val string) (int, bool)

Find will locate the existence of a given value in a slice. Returns the index of the value and whether the value was found.

func GetPageContentAsGoQuery

func GetPageContentAsGoQuery(client *http.Client, resource string) (*goquery.Document, error)

func IsMaintenanceMode

func IsMaintenanceMode(client EaClient) bool

func SetStructValues

func SetStructValues(structType reflect.Type, structValue reflect.Value, data map[string]string)

SetStructValues will set the values of a struct based on a "tag" using data provided in the map.

func ShiftJISBytesToUTF8Bytes

func ShiftJISBytesToUTF8Bytes(text []byte) []byte

ShiftJISBytesToUTF8Bytes will convert a SHIFT-JIS encoded string into a UTF-8 encoded string.

func ShiftJISStringToUTF8String

func ShiftJISStringToUTF8String(text string) string

ShiftJISStringToUTF8String will convert a SHIFT-JIS encoded string into a UTF-8 encoded string.

func TableThTd

func TableThTd(selection *goquery.Selection) (map[string]string, error)

TableThTd will attempt to separate th/td fields of a table into key:value pairs.

Types

type ClientRateLimiter

type ClientRateLimiter struct {
	Proxy             http.RoundTripper
	WeightedSemaphore *semaphore.Weighted
}

func (ClientRateLimiter) RoundTrip

func (crl ClientRateLimiter) RoundTrip(req *http.Request) (*http.Response, error)

type EaClient

type EaClient struct {
	Client *http.Client

	ActiveCookie string
	// contains filtered or unexported fields
}

func GenerateClient

func GenerateClient() EaClient

GenerateClient will generate a http.client that is used by this library.

func (*EaClient) GetEaCookie

func (client *EaClient) GetEaCookie() *http.Cookie

func (*EaClient) GetUsername

func (client *EaClient) GetUsername() string

func (*EaClient) LoginState

func (client *EaClient) LoginState() bool

func (*EaClient) SetEaCookie

func (client *EaClient) SetEaCookie(cookie *http.Cookie)

func (*EaClient) SetTestClient

func (client *EaClient) SetTestClient(testServer *httptest.Server, responseMap map[string]string)

setClient is in place to replace the internal client with a test client

func (*EaClient) SetUsername

func (client *EaClient) SetUsername(un string)

type EaJar

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

func NewJar

func NewJar() *EaJar

func (*EaJar) Cookies

func (jar *EaJar) Cookies(u *url.URL) []*http.Cookie

Cookies returns the cookies to send in a request for the given URL. It is up to the implementation to honor the standard cookie use restrictions such as in RFC 6265.

func (*EaJar) SetCookies

func (jar *EaJar) SetCookies(u *url.URL, cookies []*http.Cookie)

SetCookies handles the receipt of the cookies in a reply for the given URL. It may or may not choose to save the cookies, depending on the jar's policy and implementation.

type TestClientProxy

type TestClientProxy struct {
	Proxy       http.RoundTripper
	ResponseMap map[string]string
}

func (TestClientProxy) RoundTrip

func (tcp TestClientProxy) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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