Documentation
¶
Overview ¶
Package curlimport turns a curl command line into a `.http` request block, the reverse of `apic curl`: the common flags map onto the request line, headers, body and auth; the rest is reported, never fatal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Name ¶
Name derives a request name from the method and path when --name is not given: `POST /todos/42` becomes post-todos-42.
func Render ¶
Render writes the request as a `###` block. baseURL, when it prefixes the URL, is replaced by {{baseUrl}}.
func SplitsBlock ¶
SplitsBlock reports whether the inline body would be misread by the .http parser: a line starting with ### opens a new request block and a body starting with `< ` refers to a file. Such a body belongs in a side file (BodyFile).
Types ¶
type Part ¶
type Part struct {
Name string
Value string
File string // name=@path
Filename string // ;filename=
ContentType string // ;type=
}
Part is one -F field.
type Request ¶
type Request struct {
Method string
URL string
Headers []Header
Body string // inline body
BodyFile string // `-d @file`: sent as `< ./file`
Parts []Part // -F fields, a multipart body
User string // -u user:password, as `# @auth basic`
Insecure bool // -k
Follow bool // -L
// HTTPVersion is HTTP/1.1 for --http1.1 and HTTP/2 for --http2, written
// on the request line; empty otherwise.
HTTPVersion string
Warnings []string
}
Request is what a curl command line asked for.