Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateCertAndKeyForTestWebserver(ctx context.Context) (certAndKeyPair *x509utils.X509CertKeyPair, err error)
- func SendRequestAndGetBodyAsString(ctx context.Context, requestOptions *RequestOptions) (response string, err error)
- type Client
- type DownloadAsFileOptions
- func (d *DownloadAsFileOptions) GetDeepCopy() (copy *DownloadAsFileOptions)
- func (d *DownloadAsFileOptions) GetOutputPath() (outputPath string, err error)
- func (d *DownloadAsFileOptions) GetOverwriteExisting() (overwriteExisting bool)
- func (d *DownloadAsFileOptions) GetRequestOptions() (requestOptions *RequestOptions, err error)
- func (d *DownloadAsFileOptions) SetOutputPath(outputPath string) (err error)
- func (d *DownloadAsFileOptions) SetOverwriteExisting(overwriteExisting bool)
- func (d *DownloadAsFileOptions) SetRequestOptions(requestOptions *RequestOptions) (err error)
- type GenericResponse
- func (g *GenericResponse) GetBody() (body []byte, err error)
- func (g *GenericResponse) GetBodyAsString() (body string, err error)
- func (g *GenericResponse) GetStatusCode() (statusCode int, err error)
- func (g *GenericResponse) IsStatusCodeOk() (isStatusCodeOk bool, err error)
- func (g *GenericResponse) RunYqQueryAgainstBody(query string) (result string, err error)
- func (g *GenericResponse) SetBody(body []byte) (err error)
- func (g *GenericResponse) SetStatusCode(statusCode int) (err error)
- type NativeClient
- func (n *NativeClient) DownloadAsFile(ctx context.Context, downloadOptions *DownloadAsFileOptions) (downloadedFile files.File, err error)
- func (n *NativeClient) DownloadAsTemporaryFile(ctx context.Context, downloadOptions *DownloadAsFileOptions) (downloadedFile files.File, err error)
- func (c *NativeClient) SendRequest(ctx context.Context, requestOptions *RequestOptions) (response Response, err error)
- func (c *NativeClient) SendRequestAndGetBodyAsString(ctx context.Context, requestOptions *RequestOptions) (responseBody string, err error)
- func (c *NativeClient) SendRequestAndRunYqQueryAgainstBody(ctx context.Context, requestOptions *RequestOptions, query string) (result string, err error)
- type RequestOptions
- func (r *RequestOptions) GetDeepCopy() (copy *RequestOptions)
- func (r *RequestOptions) GetMethod() (method string, err error)
- func (r *RequestOptions) GetMethodOrDefault() (method string, err error)
- func (r *RequestOptions) GetPort() (port int, err error)
- func (r *RequestOptions) GetSkipTLSvalidation() (skipTLSvalidation bool)
- func (r *RequestOptions) GetUrl() (url string, err error)
- func (r *RequestOptions) IsMethodSet() (isSet bool)
- func (r *RequestOptions) SetMethod(method string) (err error)
- func (r *RequestOptions) SetPort(port int) (err error)
- func (r *RequestOptions) SetSkipTLSvalidation(skipTLSvalidation bool)
- func (r *RequestOptions) SetUrl(url string) (err error)
- type Response
- type Server
- type TestWebServer
- func (t *TestWebServer) GetMux() (mux *http.ServeMux, err error)
- func (t *TestWebServer) GetPort() (port int, err error)
- func (t *TestWebServer) GetServer() (server *http.Server, err error)
- func (t *TestWebServer) GetTlsCert() (cert *x509.Certificate, err error)
- func (t *TestWebServer) GetWebServerWaitGroup() (webServerWaitGroup *sync.WaitGroup, err error)
- func (t *TestWebServer) SetMux(mux *http.ServeMux) (err error)
- func (t *TestWebServer) SetPort(port int) (err error)
- func (t *TestWebServer) SetServer(server *http.Server) (err error)
- func (t *TestWebServer) SetTlsCertAndKey(ctx context.Context, certAndKey *x509utils.X509CertKeyPair) (err error)
- func (t *TestWebServer) SetWebServerWaitGroup(webServerWaitGroup *sync.WaitGroup) (err error)
- func (t *TestWebServer) StartInBackground(ctx context.Context) (err error)
- func (t *TestWebServer) Stop(ctx context.Context) (err error)
Constants ¶
View Source
const STATUS_CODE_OK = 200
Variables ¶
View Source
var ErrWebServerAlreadyRunning = errors.New("web server already running")
Functions ¶
func GenerateCertAndKeyForTestWebserver ¶ added in v0.314.0
func GenerateCertAndKeyForTestWebserver(ctx context.Context) (certAndKeyPair *x509utils.X509CertKeyPair, err error)
func SendRequestAndGetBodyAsString ¶
func SendRequestAndGetBodyAsString(ctx context.Context, requestOptions *RequestOptions) (response string, err error)
Types ¶
type Client ¶
type Client interface { DownloadAsFile(ctx context.Context, downloadOptions *DownloadAsFileOptions) (downloadedFile files.File, err error) DownloadAsTemporaryFile(ctx context.Context, downloadOptions *DownloadAsFileOptions) (downloadedFile files.File, err error) SendRequest(ctx context.Context, requestOptions *RequestOptions) (response Response, err error) SendRequestAndGetBodyAsString(ctx context.Context, requestOptions *RequestOptions) (responseBody string, err error) SendRequestAndRunYqQueryAgainstBody(ctx context.Context, requestOptions *RequestOptions, query string) (result string, err error) }
func GetNativeClient ¶
func GetNativeClient() (client Client)
Get the HTTP client written using native go http implementation.
This is the default client to use when sending request from your running machine.
type DownloadAsFileOptions ¶
type DownloadAsFileOptions struct { RequestOptions *RequestOptions OutputPath string OverwriteExisting bool // If Sha256Sum is set: // - The download will be skipped if OutputPath has already the expected content. // - The download is validated. Sha256Sum string }
func NewDownloadAsFileOptions ¶
func NewDownloadAsFileOptions() (d *DownloadAsFileOptions)
func (*DownloadAsFileOptions) GetDeepCopy ¶
func (d *DownloadAsFileOptions) GetDeepCopy() (copy *DownloadAsFileOptions)
func (*DownloadAsFileOptions) GetOutputPath ¶
func (d *DownloadAsFileOptions) GetOutputPath() (outputPath string, err error)
func (*DownloadAsFileOptions) GetOverwriteExisting ¶
func (d *DownloadAsFileOptions) GetOverwriteExisting() (overwriteExisting bool)
func (*DownloadAsFileOptions) GetRequestOptions ¶
func (d *DownloadAsFileOptions) GetRequestOptions() (requestOptions *RequestOptions, err error)
func (*DownloadAsFileOptions) SetOutputPath ¶
func (d *DownloadAsFileOptions) SetOutputPath(outputPath string) (err error)
func (*DownloadAsFileOptions) SetOverwriteExisting ¶
func (d *DownloadAsFileOptions) SetOverwriteExisting(overwriteExisting bool)
func (*DownloadAsFileOptions) SetRequestOptions ¶
func (d *DownloadAsFileOptions) SetRequestOptions(requestOptions *RequestOptions) (err error)
type GenericResponse ¶
type GenericResponse struct {
// contains filtered or unexported fields
}
This is the generic response type. It can also be seen as the default response to use.
func NewGenericResponse ¶
func NewGenericResponse() (g *GenericResponse)
func (*GenericResponse) GetBody ¶
func (g *GenericResponse) GetBody() (body []byte, err error)
func (*GenericResponse) GetBodyAsString ¶
func (g *GenericResponse) GetBodyAsString() (body string, err error)
func (*GenericResponse) GetStatusCode ¶
func (g *GenericResponse) GetStatusCode() (statusCode int, err error)
func (*GenericResponse) IsStatusCodeOk ¶
func (g *GenericResponse) IsStatusCodeOk() (isStatusCodeOk bool, err error)
func (*GenericResponse) RunYqQueryAgainstBody ¶
func (g *GenericResponse) RunYqQueryAgainstBody(query string) (result string, err error)
func (*GenericResponse) SetBody ¶
func (g *GenericResponse) SetBody(body []byte) (err error)
func (*GenericResponse) SetStatusCode ¶
func (g *GenericResponse) SetStatusCode(statusCode int) (err error)
type NativeClient ¶
type NativeClient struct { }
HTTP client written using native go http implementation.
func NewNativeClient ¶
func NewNativeClient() (n *NativeClient)
func (*NativeClient) DownloadAsFile ¶
func (n *NativeClient) DownloadAsFile(ctx context.Context, downloadOptions *DownloadAsFileOptions) (downloadedFile files.File, err error)
func (*NativeClient) DownloadAsTemporaryFile ¶
func (n *NativeClient) DownloadAsTemporaryFile(ctx context.Context, downloadOptions *DownloadAsFileOptions) (downloadedFile files.File, err error)
func (*NativeClient) SendRequest ¶
func (c *NativeClient) SendRequest(ctx context.Context, requestOptions *RequestOptions) (response Response, err error)
func (*NativeClient) SendRequestAndGetBodyAsString ¶
func (c *NativeClient) SendRequestAndGetBodyAsString(ctx context.Context, requestOptions *RequestOptions) (responseBody string, err error)
func (*NativeClient) SendRequestAndRunYqQueryAgainstBody ¶
func (c *NativeClient) SendRequestAndRunYqQueryAgainstBody(ctx context.Context, requestOptions *RequestOptions, query string) (result string, err error)
type RequestOptions ¶
type RequestOptions struct { // Url to request Url string // Port to use. // Overrides the port defined in URL if specified. Port int // Request method like GET, POST... Method string // Skip TLS validation SkipTLSvalidation bool }
func NewRequestOptions ¶
func NewRequestOptions() (r *RequestOptions)
func (*RequestOptions) GetDeepCopy ¶
func (r *RequestOptions) GetDeepCopy() (copy *RequestOptions)
func (*RequestOptions) GetMethod ¶
func (r *RequestOptions) GetMethod() (method string, err error)
func (*RequestOptions) GetMethodOrDefault ¶
func (r *RequestOptions) GetMethodOrDefault() (method string, err error)
func (*RequestOptions) GetPort ¶
func (r *RequestOptions) GetPort() (port int, err error)
func (*RequestOptions) GetSkipTLSvalidation ¶
func (r *RequestOptions) GetSkipTLSvalidation() (skipTLSvalidation bool)
func (*RequestOptions) GetUrl ¶
func (r *RequestOptions) GetUrl() (url string, err error)
func (*RequestOptions) IsMethodSet ¶
func (r *RequestOptions) IsMethodSet() (isSet bool)
func (*RequestOptions) SetMethod ¶
func (r *RequestOptions) SetMethod(method string) (err error)
func (*RequestOptions) SetPort ¶
func (r *RequestOptions) SetPort(port int) (err error)
func (*RequestOptions) SetSkipTLSvalidation ¶
func (r *RequestOptions) SetSkipTLSvalidation(skipTLSvalidation bool)
func (*RequestOptions) SetUrl ¶
func (r *RequestOptions) SetUrl(url string) (err error)
type Response ¶
type Response interface { GetBodyAsString() (body string, err error) IsStatusCodeOk() (isStatusCodeOK bool, err error) SetBody(body []byte) (err error) SetStatusCode(statusCode int) (err error) RunYqQueryAgainstBody(query string) (result string, err error) }
func SendRequest ¶ added in v0.314.0
func SendRequest(ctx context.Context, requestOptions *RequestOptions) (Response, error)
type Server ¶
type Server interface { GetPort() (port int, err error) StartInBackground(ctx context.Context) (err error) Stop(ctx context.Context) (err error) }
func GetTestWebServer ¶
type TestWebServer ¶
type TestWebServer struct {
// contains filtered or unexported fields
}
A simple webserver mostly used for testing.
func NewTestWebServer ¶
func NewTestWebServer() (t *TestWebServer)
func (*TestWebServer) GetPort ¶
func (t *TestWebServer) GetPort() (port int, err error)
func (*TestWebServer) GetServer ¶
func (t *TestWebServer) GetServer() (server *http.Server, err error)
func (*TestWebServer) GetTlsCert ¶
func (t *TestWebServer) GetTlsCert() (cert *x509.Certificate, err error)
func (*TestWebServer) GetWebServerWaitGroup ¶
func (t *TestWebServer) GetWebServerWaitGroup() (webServerWaitGroup *sync.WaitGroup, err error)
func (*TestWebServer) SetPort ¶
func (t *TestWebServer) SetPort(port int) (err error)
func (*TestWebServer) SetServer ¶
func (t *TestWebServer) SetServer(server *http.Server) (err error)
func (*TestWebServer) SetTlsCertAndKey ¶
func (t *TestWebServer) SetTlsCertAndKey(ctx context.Context, certAndKey *x509utils.X509CertKeyPair) (err error)
func (*TestWebServer) SetWebServerWaitGroup ¶
func (t *TestWebServer) SetWebServerWaitGroup(webServerWaitGroup *sync.WaitGroup) (err error)
func (*TestWebServer) StartInBackground ¶
func (t *TestWebServer) StartInBackground(ctx context.Context) (err error)
Click to show internal directories.
Click to hide internal directories.