Documentation ¶
Index ¶
- func APIHandler(uc common.UserConfig) http.Handler
- func FetchUserData(uc common.UserConfig) (*client.User, error)
- func GetHTTPClient() *http.Client
- 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 MigrateDeviceID(uc common.UserConfig, oldDeviceID string) error
- 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 ¶
This section is empty.
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 GetHTTPClient ¶
GetHTTPClient creates a new http.Client that uses domain fronting and direct proxies.
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 MigrateDeviceID ¶
func MigrateDeviceID(uc common.UserConfig, oldDeviceID string) error
MigrateDeviceID migrates the user's device ID from the old to the new scheme (only relevant to desktop builds)
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.