Documentation
¶
Overview ¶
Package httputil provides helpers for constructing multipart HTTP requests.
Index ¶
- Variables
- func CheckStatus(resp *http.Response, prefix string) error
- func Post(url, contentType string, body io.Reader) (*http.Response, error)
- func PostForm(endpoint string, data url.Values) (*http.Response, error)
- func PostMultipart(url string, upload FileUpload, fields [][2]string) (*http.Response, error)
- func ReadSnippet(r io.Reader) string
- type FileUpload
Constants ¶
This section is empty.
Variables ¶
View Source
var Client = &http.Client{Timeout: 30 * time.Second}
Client is a shared HTTP client with a 30-second timeout, used by all remote step packages to avoid indefinite hangs on unresponsive servers.
Functions ¶
func CheckStatus ¶ added in v0.2.11
CheckStatus returns an error if the response status code is not 2xx. The prefix is included in the error message for context (e.g. "discord: webhook").
func PostMultipart ¶ added in v0.2.21
PostMultipart builds a multipart form with a file attachment and text fields, then POSTs it using the shared Client. Fields are written before the file.
func ReadSnippet ¶
ReadSnippet reads up to 200 bytes from r for inclusion in error messages.
Types ¶
type FileUpload ¶ added in v0.2.21
type FileUpload struct {
FieldName string // form field name (e.g. "file", "audio", "voice")
FilePath string // path to the file on disk
ContentType string // MIME type; empty uses application/octet-stream
}
FileUpload describes a file to include in a multipart form POST.
Click to show internal directories.
Click to hide internal directories.