httpie

package
v0.0.0-...-1be0f7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	GET     Method = "GET"
	POST    Method = "POST"
	PUT     Method = "PUT"
	DELETE  Method = "DELETE"
	PATCH   Method = "PATCH"
	HEAD    Method = "HEAD"
	OPTIONS Method = "OPTIONS"
	TRACE   Method = "TRACE"
	CONNECT Method = "CONNECT"

	HTTP  Scheme = "http"
	HTTPS Scheme = "https"
)

Variables

View Source
var (
	Blue   = color.New(color.FgBlue).SprintFunc()
	Red    = color.New(color.FgRed).SprintFunc()
	Green  = color.New(color.FgGreen).SprintFunc()
	Yellow = color.New(color.FgYellow).SprintFunc()
	Cyan   = color.New(color.FgCyan).SprintFunc()
)

Functions

func AddSchema

func AddSchema(rawUrl string, scheme Scheme) (string, error)

AddSchema adds the schema to the URL if it is missing.

func PrintBody

func PrintBody(resp *requests4go.Response) error

func PrintHeaders

func PrintHeaders(resp *requests4go.Response)

func Request

func Request(method Method, url string, args []string) error

Types

type ArgsParser

type ArgsParser interface {
	// Headers returns the headers from the args.
	// "foo:bar" => map[string]string{"foo": "bar"}
	Headers() map[string]string
	// QueryParams returns the query from the args.
	// "foo=bar" => map[string]string{"foo": "bar"}
	QueryParams() map[string]string
}

func NewDefaultParser

func NewDefaultParser(args []string) ArgsParser

type DefaultParser

type DefaultParser struct {
	// contains filtered or unexported fields
}

func (*DefaultParser) Headers

func (p *DefaultParser) Headers() map[string]string

Headers parses header from args

Example
p := NewDefaultParser([]string{"Accept: application/json", "User-Agent: httpie"})
fmt.Println(p.Headers())
Output:

map[Accept:application/json User-Agent:httpie]

func (*DefaultParser) QueryParams

func (p *DefaultParser) QueryParams() map[string]string
Example
p := NewDefaultParser([]string{"foo==bar"})
fmt.Println(p.QueryParams())
Output:

map[foo:bar]

type Method

type Method = string

type Scheme

type Scheme = string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL