Documentation ¶
Index ¶
- Variables
- func APIHandler(uc common.UserConfig) http.Handler
- func FetchUserData(uc common.UserConfig) (*client.User, error)
- func GetUserDataFast(userID int64) (*client.User, bool)
- func IsProUser(uc common.UserConfig) (isPro bool, statusKnown bool)
- func IsProUserFast(uc common.UserConfig) (isPro bool, statusKnown bool)
- func NewClient() *client.Client
- func NewUser(uc common.UserConfig) (*client.User, error)
- func OnProStatusChange(cb func(isPro bool, yinbiEnabled bool))
- func OnUserData(cb func(current *client.User, new *client.User))
- func PrepareProRequest(r *http.Request, uc common.UserConfig)
- func PrepareProRequestWithOptions(r *http.Request, uc common.UserConfig)
Constants ¶
This section is empty.
Variables ¶
var HTTPClient = &http.Client{ Transport: proxied.ParallelForIdempotent(), CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, Timeout: 30 * time.Second, }
Functions ¶
func APIHandler ¶
func APIHandler(uc common.UserConfig) http.Handler
APIHandler returns an HTTP handler that specifically looks for and properly handles pro server requests.
func FetchUserData ¶
func FetchUserData(uc common.UserConfig) (*client.User, error)
FetchUserData fetches user data from Pro API, and updates local cache.
func GetUserDataFast ¶
GetUserDataFast gets the user data for the given userID if found.
func IsProUser ¶
func IsProUser(uc common.UserConfig) (isPro bool, statusKnown bool)
IsProUser indicates whether or not the user is pro, calling the Pro API if necessary to determine the status.
func IsProUserFast ¶
func IsProUserFast(uc common.UserConfig) (isPro bool, statusKnown bool)
IsProUserFast indicates whether or not the user is pro and whether or not the user's status is know, never calling the Pro API to determine the status.
func NewUser ¶
func NewUser(uc common.UserConfig) (*client.User, error)
NewUser creates a new user via Pro API, and updates local cache.
func OnProStatusChange ¶
OnProStatusChange allows registering an event handler to learn when the user's pro status or "yinbi enabled" status has changed.
func OnUserData ¶
OnUserData allows registering an event handler to learn when the user data has been fetched.
func PrepareProRequest ¶
func PrepareProRequest(r *http.Request, uc common.UserConfig)
PrepareProRequest normalizes requests to the pro server without overwriting device ID, user ID, etc.
func PrepareProRequestWithOptions ¶
func PrepareProRequestWithOptions(r *http.Request, uc common.UserConfig)
PrepareProRequestWithOptions normalizes requests to the pro server with device ID, user ID, etc set.
Types ¶
This section is empty.