middlewares

package
v0.0.0-...-17a28f7 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBasicAuthConfig = BasicAuthConfig{}

DefaultBasicAuthConfig is the default BasicAuth middleware config.

View Source
var DefaultDecoderConfig struct{}

DefaultDecoderConfig is the default Decoder middleware config.

View Source
var DefaultDownLimiterConfig = DownLimiterConfig{
	ConcurrentRequestsPerDomain: 1024,
	DownloadDelayPerDomain:      0,
	Timeout:                     3 * time.Second,
}

DefaultDownLimiterConfig is the default DownLimiter middleware config.

View Source
var DefaultLoggingConfig struct{}

DefaultLoggingConfig is the default Logging middleware config.

View Source
var DefaultRetryConfig = RetryConfig{
	RetryTimes: 3,
}

DefaultRetryConfig is the default Retry middleware config.

View Source
var DefaultStatsCollectorConfig = StatsCollectorConfig{}

DefaultStatsCollectorConfig is the default StatsCollector middleware config.

Functions

This section is empty.

Types

type BasicAuth

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

BasicAuth for decode response body to utf8

func NewBasicAuth

func NewBasicAuth() *BasicAuth

NewBasicAuth returns a BasicAuth instance

func NewBasicAuthWithConfig

func NewBasicAuthWithConfig(config BasicAuthConfig) *BasicAuth

NewBasicAuthWithConfig returns a BasicAuth middleware with config. See: `NewBasicAuth()`.

func (*BasicAuth) Next

Next implement mellivora.Middleware.Next

type BasicAuthConfig

type BasicAuthConfig struct {
	UserName string
	Password string
}

BasicAuthConfig defines the config for BasicAuth middleware.

type Decoder

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

Decoder for decode response body to utf8

func NewDecoder

func NewDecoder() *Decoder

NewDecoder returns a Decoder instance

func NewDecoderWithConfig

func NewDecoderWithConfig(config DecoderConfig) *Decoder

NewDecoderWithConfig returns a Decoder middleware with config. See: `NewDecoder()`.

func (*Decoder) Next

Next implement mellivora.Middleware.Next

type DecoderConfig

type DecoderConfig struct{}

DecoderConfig defines the config for Decoder middleware.

type DownLimiter

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

DownLimiter for limit downloader

func NewDownLimiter

func NewDownLimiter() *DownLimiter

NewDownLimiter returns a DownLimiter instance

func NewDownLimiterWithConfig

func NewDownLimiterWithConfig(config DownLimiterConfig) *DownLimiter

NewDownLimiterWithConfig returns a DownLimiter middleware with config. See: `DownLimiter()`.

func (*DownLimiter) Next

Next implement mellivora.Middleware.Next

type DownLimiterConfig

type DownLimiterConfig struct {
	// ConcurrentRequestsPerDomain 每个域名下请求并行限制
	ConcurrentRequestsPerDomain uint64
	// DownloadDelayPerDomain 每个域名下请求的延时
	DownloadDelayPerDomain time.Duration
	// Timeout 请求超时
	Timeout time.Duration
}

DownLimiterConfig defines the config for DownLimiter middleware.

type Logging

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

Logging log access

func NewLogging

func NewLogging() *Logging

NewLogging returns a Logging instance

func NewLoggingWithConfig

func NewLoggingWithConfig(config LoggingConfig) *Logging

NewLoggingWithConfig returns a Logging middleware with config. See: `NewLogging()`.

func (*Logging) Next

Next implement mellivora.Next

type LoggingConfig

type LoggingConfig struct{}

LoggingConfig defines the config for Logging middleware.

type Retry

type Retry struct {
	RetryConfig
}

Retry defines a middleware which Retrys from panics anywhere in the chain

func NewRetry

func NewRetry() *Retry

NewRetry returns a Retry instance

func NewRetryWithConfig

func NewRetryWithConfig(config RetryConfig) *Retry

NewRetryWithConfig returns a Retry middleware with config. See: `NewRetry()`.

func (*Retry) Next

Next implement mellivora.Middleware.Next

type RetryConfig

type RetryConfig struct {
	RetryTimes int
}

RetryConfig defines the config for Retry middleware.

type StatsCollector

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

StatsCollector for collecting scraping stats

func NewStatsCollector

func NewStatsCollector() *StatsCollector

NewStatsCollector returns a StatsCollector instance

func NewStatsCollectorWithConfig

func NewStatsCollectorWithConfig(config StatsCollectorConfig) *StatsCollector

NewStatsCollectorWithConfig returns a StatsCollector middleware with config. See: `NewStatsCollector()`.

func (*StatsCollector) Close

func (s *StatsCollector) Close(c *mellivora.Engine)

Close implement mellivora.Closer

func (*StatsCollector) Next

Next implement mellivora.StatsCollector.Next

type StatsCollectorConfig

type StatsCollectorConfig struct{}

StatsCollectorConfig defines the config for StatsCollector middleware.

Jump to

Keyboard shortcuts

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