requests

package
v0.0.0-...-4a54890 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 13 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

	AuthenticationRequired = http.StatusNetworkAuthenticationRequired
	Unauthorized           = http.StatusUnauthorized
)

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 GetCertificateInfo

func GetCertificateInfo(w http.ResponseWriter, r *http.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

Uses date from request Config and creates and executes http request

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"`
	Environment  string            `json:"environment"`
	Priority     string            `json:"priority"`
	RequestType  string            `json:"requestType"`
	Headers      map[string]string `json:"headers"`
	FormParams   map[string]string `json:"formParams"`
	UrlParams    map[string]string `json:"urlParams"`
	Tags         []string          `json:"tags"`
	Details      map[string]string `json:"details"`
	ResponseCode int               `json:"responseCode"`
	ResponseTime int64             `json:"responseTime"`
	ResponseBody string            `json:"responseBody"`
	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 all request Config fields are valid

Jump to

Keyboard shortcuts

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