options

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultSortOption     = "count"
	DefaultFormatOption   = "table"
	DefaultLimitOption    = 5000
	DefaultLocationOption = "Local"
	DefaultOutputOption   = "all"
	// ltsv
	DefaultApptimeLabelOption = "apptime"
	DefaultReqtimeLabelOption = "reqtime"
	DefaultStatusLabelOption  = "status"
	DefaultSizeLabelOption    = "size"
	DefaultMethodLabelOption  = "method"
	DefaultUriLabelOption     = "uri"
	DefaultTimeLabelOption    = "time"
	// json
	DefaultUriKeyOption          = "uri"
	DefaultMethodKeyOption       = "method"
	DefaultTimeKeyOption         = "time"
	DefaultResponseTimeKeyOption = "response_time"
	DefaultRequestTimeKeyOption  = "request_time"
	DefaultBodyBytesKeyOption    = "body_bytes"
	DefaultStatusKeyOption       = "status"
	// regexp
	DefaultPatternOption = `^(\S+)\s` +
		`\S+\s+` +
		`(\S+\s+)+` +
		`\[(?P<time>[^]]+)\]\s` +
		`"(?P<method>\S*)\s?` +
		`(?P<uri>(?:[^"]*(?:\\")?)*)\s` +
		`([^"]*)"\s` +
		`(?P<status>\S+)\s` +
		`(?P<body_bytes>\S+)\s` +
		`"((?:[^"]*(?:\\")?)*)"\s` +
		`"(?:.+)"` +
		`\s(?P<response_time>\S+)(?:\s(?P<request_time>\S+))?$`
	DefaultUriSubexpOption          = "uri"
	DefaultMethodSubexpOption       = "method"
	DefaultTimeSubexpOption         = "time"
	DefaultResponseTimeSubexpOption = "response_time"
	DefaultRequestTimeSubexpOption  = "request_time"
	DefaultBodyBytesSubexpOption    = "body_bytes"
	DefaultStatusSubexpOption       = "status"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONOptions

type JSONOptions struct {
	UriKey          string `yaml:"uri_key"`
	MethodKey       string `yaml:"method_key"`
	TimeKey         string `yaml:"time_key"`
	ResponseTimeKey string `yaml:"response_time_key"`
	RequestTimeKey  string `yaml:"request_time_key"`
	BodyBytesKey    string `yaml:"body_bytes_key"`
	StatusKey       string `yaml:"status_key"`
}

type LTSVOptions

type LTSVOptions struct {
	ApptimeLabel string `yaml:"apptime_label"`
	ReqtimeLabel string `yaml:"reqtime_label"`
	StatusLabel  string `yaml:"status_label"`
	SizeLabel    string `yaml:"size_label"`
	MethodLabel  string `yaml:"method_label"`
	UriLabel     string `yaml:"uri_label"`
	TimeLabel    string `yaml:"time_label"`
}

type Option

type Option func(*Options)

func ApptimeLabel

func ApptimeLabel(s string) Option

ltsv

func BodyBytesKey

func BodyBytesKey(s string) Option

func BodyBytesSubexp

func BodyBytesSubexp(s string) Option

func CSVGroups

func CSVGroups(csv string) Option

func File

func File(s string) Option

func Filters

func Filters(s string) Option

func Format

func Format(s string) Option

func Limit

func Limit(i int) Option

func Location

func Location(s string) Option

func MatchingGroups

func MatchingGroups(values []string) Option

func MethodKey

func MethodKey(s string) Option

func MethodLabel

func MethodLabel(s string) Option

func MethodSubexp

func MethodSubexp(s string) Option

func NoHeaders

func NoHeaders(b bool) Option

func NoSavePos

func NoSavePos(b bool) Option

func Output

func Output(s string) Option

func Pattern

func Pattern(s string) Option

regexp

func PosFile

func PosFile(s string) Option

func QueryString

func QueryString(b bool) Option

func ReqtimeLabel added in v1.0.1

func ReqtimeLabel(s string) Option

func RequestTimeKey added in v1.0.1

func RequestTimeKey(s string) Option

func RequestTimeSubexp added in v1.0.1

func RequestTimeSubexp(s string) Option

func ResponseTimeKey

func ResponseTimeKey(s string) Option

func ResponseTimeSubexp

func ResponseTimeSubexp(s string) Option

func Reverse

func Reverse(b bool) Option

func ShowFooters

func ShowFooters(b bool) Option

func SizeLabel

func SizeLabel(s string) Option

func Sort

func Sort(s string) Option

func StatusKey

func StatusKey(s string) Option

func StatusLabel

func StatusLabel(s string) Option

func StatusSubexp

func StatusSubexp(s string) Option

func TimeKey

func TimeKey(s string) Option

func TimeLabel

func TimeLabel(s string) Option

func TimeSubexp

func TimeSubexp(s string) Option

func UriKey

func UriKey(s string) Option

json

func UriLabel

func UriLabel(s string) Option

func UriSubexp

func UriSubexp(s string) Option

type Options

type Options struct {
	File           string         `yaml:"file"`
	Sort           string         `yaml:"sort"`
	Reverse        bool           `yaml:"reverse"`
	QueryString    bool           `yaml:"query_string"`
	Format         string         `yaml:"format"`
	NoHeaders      bool           `yaml:"noheaders"`
	ShowFooters    bool           `yaml:"show_footers"`
	Limit          int            `yaml:"limit"`
	MatchingGroups []string       `yaml:"matching_groups"`
	Filters        string         `yaml:"filters"`
	PosFile        string         `yaml:"pos_file"`
	NoSavePos      bool           `yaml:"nosave_pos"`
	Location       string         `yaml:"location"`
	Output         string         `yaml:"output"`
	LTSV           *LTSVOptions   `yaml:"ltsv"`
	Regexp         *RegexpOptions `yaml:"regexp"`
	JSON           *JSONOptions   `yaml:"json"`
}

func LoadOptionsFromReader

func LoadOptionsFromReader(r io.Reader) (*Options, error)

func NewOptions

func NewOptions(opt ...Option) *Options

func SetOptions

func SetOptions(options *Options, opt ...Option) *Options

type RegexpOptions

type RegexpOptions struct {
	Pattern            string `yaml:"pattern"`
	UriSubexp          string `yaml:"uri_subexp"`
	MethodSubexp       string `yaml:"method_subexp"`
	TimeSubexp         string `yaml:"time_subexp"`
	ResponseTimeSubexp string `yaml:"response_time_subexp"`
	RequestTimeSubexp  string `yaml:"request_time_subexp"`
	BodyBytesSubexp    string `yaml:"body_bytes_subexp"`
	StatusSubexp       string `yaml:"status_subexp"`
}

Jump to

Keyboard shortcuts

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