utilgo.mau.fi/util/curl Index | Files

package curl

import "go.mau.fi/util/curl"

Index

Functions

func Format

func Format(cli *http.Client, req *http.Request) string

Format formats the given HTTP request as a curl command.

This will include all headers, and also the request body if GetBody is set. Notes:

* Header names are quoted using fmt.Sprintf, so it may not always be correct for shell quoting. * The URL is only quoted and not escaped, so URLs with single quotes will not currently work.

The client parameter is optional and is used to find cookies from the cookie jar.

Types

type Parsed

type Parsed struct {
	*http.Request
	ParsedJSON map[string]any
}

func Parse

func Parse(curl string) (*Parsed, error)

Source Files

format.go parse.go

Version
v0.8.6 (latest)
Published
Mar 16, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
1 week ago

Tools for package owners.