api

package
v0.0.0-...-66313eb Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestsPerSecond = 2
	RequestsPerHour   = 1200
	SleepBetweenTries = 100 * time.Millisecond
)
View Source
const DebugVar = "httpdebug"

Variables

View Source
var APIStats = Stats{}

Functions

func DebugRequest

func DebugRequest(req *http.Request)

func DebugResponse

func DebugResponse(res *http.Response)

func Do

func Do[T any](apiReq *APIRequest) (*T, error)

func DoPaginated

func DoPaginated[T []E, E any](apiReq *APIRequest) (chan func() (*E, error), error)

func InitClients

func InitClients(apiKeys []models.APIKey) error

func OauthAPIKey

func OauthAPIKey() *models.APIKey

func OauthToken

func OauthToken(apiKey models.APIKey, code string, next string) (string, error)

Types

type APIRequest

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

func NewRequest

func NewRequest(endpoint string) *APIRequest

func (*APIRequest) Authenticated

func (apiReq *APIRequest) Authenticated() *APIRequest

func (*APIRequest) AuthenticatedAs

func (apiReq *APIRequest) AuthenticatedAs(accessToken string) *APIRequest

func (*APIRequest) OutputHeadersIn

func (apiReq *APIRequest) OutputHeadersIn(output **http.Header) *APIRequest

func (*APIRequest) SinceLastFetch

func (apiReq *APIRequest) SinceLastFetch(db *gorm.DB, defaultTime time.Time) *APIRequest

func (*APIRequest) WithHeaders

func (apiReq *APIRequest) WithHeaders(headers map[string]string) *APIRequest

func (*APIRequest) WithMaxConcurrentFetches

func (apiReq *APIRequest) WithMaxConcurrentFetches(n int64) *APIRequest

func (*APIRequest) WithMethod

func (apiReq *APIRequest) WithMethod(method string) *APIRequest

func (*APIRequest) WithPageSize

func (apiReq *APIRequest) WithPageSize(n int) *APIRequest

func (*APIRequest) WithParams

func (apiReq *APIRequest) WithParams(params map[string]string) *APIRequest

type APIResult

type APIResult struct {
	Name   string
	AppID  string
	UID    string
	Secret string
}

type KeysManager

type KeysManager struct {
	// contains filtered or unexported fields
}
var DefaultKeysManager *KeysManager = nil

func NewKeysManager

func NewKeysManager(db *gorm.DB) (*KeysManager, error)

func (*KeysManager) CreateOne

func (manager *KeysManager) CreateOne() (*models.APIKey, error)

func (*KeysManager) DeleteAllKeys

func (manager *KeysManager) DeleteAllKeys() error

func (*KeysManager) DeleteOne

func (manager *KeysManager) DeleteOne(id int) error

func (*KeysManager) GetKeys

func (manager *KeysManager) GetKeys() ([]models.APIKey, error)

type OauthTokenResponse

type OauthTokenResponse struct {
	AccessToken string `json:"access_token"`
}

type PageCountError

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

func (PageCountError) Error

func (pageCountErr PageCountError) Error() string

type ParseError

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

func (ParseError) Error

func (parseError ParseError) Error() string

type RLHTTPClient

type RLHTTPClient struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func RateLimitedClient

func RateLimitedClient(accessToken string, apiKey models.APIKey) *RLHTTPClient

func (*RLHTTPClient) Do

func (c *RLHTTPClient) Do(req *http.Request) (*http.Response, error)

type Stats

type Stats struct {
	sync.Mutex
	RequestsSoFar int `json:"requestsSoFar"`
	TotalRequests int `json:"totalRequests"`
}

func (*Stats) Percent

func (stats *Stats) Percent() int

func (*Stats) String

func (stats *Stats) String() string

type Target

type Target struct {
	URLs    []string
	Percent float32
	ID      int
}

Jump to

Keyboard shortcuts

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