requests

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType     = "Content-Type"
	ContentLength   = "Content-Length"
	FormContentType = "application/x-www-form-urlencoded"
	JsonContentType = "application/json"

	DefaultTime         = "300s"
	DefaultResponseCode = http.StatusOK
	DefaultConcurrency  = 1
)

Variables

View Source
var (
	RequestsList []RequestConfig
)

Functions

func AddHeaders

func AddHeaders(req *http.Request, headers map[string]string)

Add header values from map to request

func GetJsonParamsBody

func GetJsonParamsBody(params map[string]string) (io.Reader, error)

Creates body for request of type application/json from map

func GetUrlValues

func GetUrlValues(params map[string]string) url.Values

convert params in map to url.Values

func PerformRequest

func PerformRequest(requestConfig RequestConfig, throttle chan int) error

takes the date from requestConfig and creates http request and executes it

func RequestsInit

func RequestsInit(data []RequestConfig, concurrency int)

Initialize data from config file and check all requests

func StartMonitoring

func StartMonitoring()

Start monitoring by calling createTicker method for each request

Types

type RequestConfig

type RequestConfig struct {
	Id           int
	Url          string            `json:"url"`
	RequestType  string            `json:"requestType"`
	Headers      map[string]string `json:"headers"`
	FormParams   map[string]string `json:"formParams"`
	UrlParams    map[string]string `json:"urlParams"`
	ResponseCode int               `json:"responseCode"`
	ResponseTime int64             `json:"responseTime"`
	CheckEvery   time.Duration     `json:"checkEvery"`
}

func (*RequestConfig) SetId

func (requestConfig *RequestConfig) SetId(id int)

Set Id for request

func (*RequestConfig) Validate

func (requestConfig *RequestConfig) Validate() error

check whether all requestConfig fields are valid

Jump to

Keyboard shortcuts

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