Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Runner lets us mock exec.Command for testing Runner = exec.Command // ErrUnknownCommand indicates the type of command is not recognized ErrUnknownCommand = fmt.Errorf("unknown command type") )
var ( // GET is a GET request GET = "GET" // POST is a POST request POST = "POST" // PUT is a PUT request PUT = "PUT" )
var ( // HTTPClient is the client Direct commands use HTTPClient = &http.Client{ Timeout: 30 * time.Second, } )
Functions ¶
This section is empty.
Types ¶
type Command ¶
Command is an individual command
func (*Command) MarshalJSON ¶
MarshalJSON encodes our Commander as `comamnd`
func (*Command) UnmarshalJSON ¶
UnmarshalJSON unmarshals our Commander interface to a struct
type Commander ¶
type Commander interface { Valid() (err error) DeParameterize(params []string) (err error) AddCredentials(credentials map[string]string) Run() (bdy []byte, err error) }
Commander outlines methods to run commands
type Curl ¶
type Curl struct {
Command string `json:"command"`
}
Curl is a cURL command
func (*Curl) AddCredentials ¶
AddCredentials adds the user's OAuth2 credentials (if applicable)
func (*Curl) DeParameterize ¶
DeParameterize replaces parameters in the cURL statement
type Direct ¶
type Direct struct { Client HTTPClienter `json:"-"` Method string `json:"method,omitempty"` Body string `json:"body,omitempty"` Provider string `json:"provider,omitempty"` Web // contains filtered or unexported fields }
Direct is a command where each component (method, headers, etc) are separate
func (*Direct) AddCredentials ¶
AddCredentials adds the user's OAuth2 credentials
func (*Direct) DeParameterize ¶
DeParameterize replaces parameters in the url, headers, and body
type HTTPClienter ¶
HTTPClienter allows for mocking the client in tests
type Response ¶
type Response struct {
Body interface{} `json:"body"`
}
Response is a command response
type Web ¶
type Web struct { URL string `json:"url"` Headers []Header `json:"headers,omitempty"` // contains filtered or unexported fields }
Web executes a command as a headless browser
func (*Web) AddCredentials ¶
AddCredentials adds the user's OAuth2 credentials (if applicable)
func (*Web) DeParameterize ¶
DeParameterize replaces parameters in the url, headers, and body