Documentation ¶
Overview ¶
Package session contains a default implementation of the session browser
Index ¶
- type DefaultSession
- func (s *DefaultSession) ApplyRateLimit()
- func (s *DefaultSession) DownloadFile(filepath string, uri string) (err error)
- func (s *DefaultSession) Get(uri string) (response *http.Response, err error)
- func (s *DefaultSession) GetClient() *http.Client
- func (s *DefaultSession) Post(uri string, data url.Values) (response *http.Response, err error)
- func (s *DefaultSession) SetClient(client *http.Client)
- func (s *DefaultSession) SetProxy(proxySettings *watcherHttp.ProxySettings) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultSession ¶
type DefaultSession struct { watcherHttp.Session Client *http.Client RateLimiter *rate.Limiter MaxRetries int // contains filtered or unexported fields }
DefaultSession is an extension to the implemented SessionInterface for HTTP sessions
func NewSession ¶
func NewSession(moduleKey string) *DefaultSession
NewSession initializes a new session and sets all the required headers etc
func (*DefaultSession) ApplyRateLimit ¶
func (s *DefaultSession) ApplyRateLimit()
ApplyRateLimit waits for the leaky bucket to fill again
func (*DefaultSession) DownloadFile ¶
func (s *DefaultSession) DownloadFile(filepath string, uri string) (err error)
DownloadFile tries to download the file, returns the occurred error if something went wrong even after multiple tries
func (*DefaultSession) Get ¶
func (s *DefaultSession) Get(uri string) (response *http.Response, err error)
Get sends a GET request, returns the occurred error if something went wrong even after multiple tries
func (*DefaultSession) GetClient ¶
func (s *DefaultSession) GetClient() *http.Client
GetClient returns the used *http.Client, required f.e. to manually set cookies
func (*DefaultSession) Post ¶
Post sends a POST request, returns the occurred error if something went wrong even after multiple tries
func (*DefaultSession) SetClient ¶
func (s *DefaultSession) SetClient(client *http.Client)
SetClient sets the used *http.Client in case we are routing the requests (for f.e. OAuth2 Authentications)
func (*DefaultSession) SetProxy ¶
func (s *DefaultSession) SetProxy(proxySettings *watcherHttp.ProxySettings) (err error)
SetProxy sets the current proxy for the client