Documentation
¶
Overview ¶
Package request contains all the things used to create requests.
Index ¶
- func BuildRequest(processedRequest Request) (*http.Request, error)
- func ParseURL(base string, paths ...string) string
- type ConfigureRequestOption
- type ConfigureRequestOptions
- type ExecutedRequestResponse
- type ExecutionContext
- type PostProcessContext
- type PostProcessSourceCode
- type Request
- func (req Request) GetAllowInsecure() bool
- func (req Request) GetBody() (string, error)
- func (req Request) GetHeaders() map[string][]string
- func (req Request) GetMethod() string
- func (req *Request) LoadBodyFromFile(fileName string) error
- func (req *Request) Merge(toMerge interface{}) error
- func (req *Request) MergeBody(toMerge string)
- func (req *Request) MergeHeaders(headers map[string][]string)
- func (req *Request) MergeOptions(optionsToMerge profile.NamedRequest)
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRequest ¶
BuildRequest builds an http.Request from a configured request.Request
Types ¶
type ConfigureRequestOption ¶
type ConfigureRequestOption func(configuration *ConfigureRequestOptions)
ConfigureRequestOption an option that can be applied on a ConfigureRequestOptions
func AddProfiles ¶
func AddProfiles(profileNames ...string) ConfigureRequestOption
AddProfiles adds a set of profiles to the configuration request
func AddValues ¶
func AddValues(values map[string][]string) ConfigureRequestOption
AddValues adds a set of values in the configuration request
func SetRequestName ¶
func SetRequestName(requestName string) ConfigureRequestOption
SetRequestName sets the named request in the configuration request
type ConfigureRequestOptions ¶
type ConfigureRequestOptions struct { ProfileNames []string RequestName string Values map[string][]string }
ConfigureRequestOptions set of options that can be used to configure a request
func CreateConfigureRequestOptions ¶
func CreateConfigureRequestOptions(passedInOptions ...ConfigureRequestOption) *ConfigureRequestOptions
CreateConfigureRequestOptions creates the options to configure a request based on the options
func (*ConfigureRequestOptions) GetValues ¶
func (config *ConfigureRequestOptions) GetValues() map[string][]string
GetValues returns the values from the configuration request
type ExecutedRequestResponse ¶
type ExecutedRequestResponse struct { Request Request Response Response PostProcessError string PostProcessOutput string }
ExecutedRequestResponse represents a pair of request and the response that was returned from its execution. It also includes any output and/or error generated during post processing.
func ExecuteRequestLoop ¶
func ExecuteRequestLoop(executionContext ExecutionContext) ([]ExecutedRequestResponse, error)
ExecuteRequestLoop executes HTTP requests based on the passed in options until there're no more requests to be executed.
type ExecutionContext ¶
type ExecutionContext struct { AllowInsecure bool FollowLocation bool MaxAddedRequests int MaxRedirect int ProfileNames []string Request Request Session *session.Session Variables map[string]string }
ExecutionContext represent the options to be passed for the request executor.
type PostProcessContext ¶
PostProcessContext stores
func PostProcess ¶
func PostProcess(sourceCode PostProcessSourceCode, executionContext *ExecutionContext, executedRequests []ExecutedRequestResponse, responseErr error) (*PostProcessContext, error)
PostProcess processes the executed requests using the post processing script
type PostProcessSourceCode ¶
type PostProcessSourceCode struct { // SourceCode is the code to be executed SourceCode string // SourceFilePath is the path to the file where the code came from SourceFilePath string }
PostProcessSourceCode represents the source code to be executed
type Request ¶
type Request struct { AllowInsecure bool Body string Cookies []*http.Cookie Headers map[string][]string Method string PostProcessCode PostProcessSourceCode QueryParams map[string][]string URL string }
Request stores data required to configure a request to be executed
func ConfigureRequest ¶
func ConfigureRequest(unconfiguredRequest Request, mergedProfile *profile.Options, configureOptions *ConfigureRequestOptions) (*Request, error)
ConfigureRequest configures a request to be executed based on the provided options
func ConfigureRequestSimple ¶
func ConfigureRequestSimple(unconfiguredRequest Request, mergedProfile *profile.Options, requestName string) (*Request, error)
ConfigureRequestSimple is a simpler version of configure request TODO - This was brute forced here to solve the post-processing issue, this code needs to be refactored
func (Request) GetAllowInsecure ¶ added in v1.2.0
GetAllowInsecure returns if this named request allow insecure HTTP connections
func (Request) GetHeaders ¶
GetHeaders returns the headers for this request
func (*Request) LoadBodyFromFile ¶
LoadBodyFromFile loads data from a file and set it to the body, if not already set
func (*Request) Merge ¶
Merge merges information from something compatible with a request into this request
func (*Request) MergeHeaders ¶
MergeHeaders merges the passed headers into the request
func (*Request) MergeOptions ¶
func (req *Request) MergeOptions(optionsToMerge profile.NamedRequest)
MergeOptions merges request options loaded from a profile