fox

package module
v0.0.0-...-3df0519 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 22 Imported by: 0

README

Fox

Logo

GoDoc Go Report Card

Fox is a CLI client for the http. Has many options and auto-completion.

Features

  • Can be used as a package.
  • CLI auto-completion.

Usage

Installation

go get -u github.com/thesayfulla/fox

Thanks

  • github.com/c-bata/go-prompt
  • github.com/parnurzeal/gorequest

Documentation

Index

Constants

View Source
const (
	POST    = "POST"
	GET     = "GET"
	HEAD    = "HEAD"
	PUT     = "PUT"
	DELETE  = "DELETE"
	PATCH   = "PATCH"
	OPTIONS = "OPTIONS"
)

HTTP methods we support

View Source
const (
	TypeJSON       = "json"
	TypeXML        = "xml"
	TypeUrlencoded = "urlencoded"
	TypeForm       = "form"
	TypeFormData   = "form-data"
	TypeHTML       = "html"
	TypeText       = "text"
	TypeMultipart  = "multipart"
)

Types we support.

Variables

View Source
var DisableTransportSwap = false
View Source
var Types = map[string]string{
	TypeJSON:       "application/json",
	TypeXML:        "application/xml",
	TypeForm:       "application/x-www-form-urlencoded",
	TypeFormData:   "application/x-www-form-urlencoded",
	TypeUrlencoded: "application/x-www-form-urlencoded",
	TypeHTML:       "text/html",
	TypeText:       "text/plain",
	TypeMultipart:  "multipart/form-data",
}

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Url               string
	Method            string
	Header            http.Header
	TargetType        string
	ForceType         string
	Data              map[string]interface{}
	SliceData         []interface{}
	FormData          url.Values
	QueryData         url.Values
	FileData          []File
	BounceToRawString bool
	RawString         string
	Client            *http.Client
	Transport         *http.Transport
	Cookies           []*http.Cookie
	Errors            []error
	BasicAuth         struct{ Username, Password string }
	Debug             bool
	CurlCommand       bool

	Retryable            superAgentRetryable
	DoNotClearSuperAgent bool
	// contains filtered or unexported fields
}

func New

func New() *Agent

func (*Agent) AddCookie

func (s *Agent) AddCookie(c *http.Cookie) *Agent

func (*Agent) AddCookies

func (s *Agent) AddCookies(cookies []*http.Cookie) *Agent

func (*Agent) AppendHeader

func (s *Agent) AppendHeader(param string, value string) *Agent

func (*Agent) AsCurlCommand

func (s *Agent) AsCurlCommand() (string, error)

func (*Agent) ClearSuperAgent

func (s *Agent) ClearSuperAgent()

func (*Agent) Clone

func (s *Agent) Clone() *Agent

func (*Agent) CustomMethod

func (s *Agent) CustomMethod(method, targetUrl string) *Agent

func (*Agent) Delete

func (s *Agent) Delete(targetUrl string) *Agent

func (*Agent) End

func (s *Agent) End(callback ...func(response Response, body string, errs []error)) (Response, string, []error)

func (*Agent) EndBytes

func (s *Agent) EndBytes(callback ...func(response Response, body []byte, errs []error)) (Response, []byte, []error)

func (*Agent) EndStruct

func (s *Agent) EndStruct(v interface{}, callback ...func(response Response, v interface{}, body []byte, errs []error)) (Response, []byte, []error)

func (*Agent) Get

func (s *Agent) Get(targetUrl string) *Agent

func (*Agent) Head

func (s *Agent) Head(targetUrl string) *Agent

func (*Agent) MakeRequest

func (s *Agent) MakeRequest() (*http.Request, error)

func (*Agent) Options

func (s *Agent) Options(targetUrl string) *Agent

func (*Agent) Param

func (s *Agent) Param(key string, value string) *Agent

func (*Agent) Patch

func (s *Agent) Patch(targetUrl string) *Agent

func (*Agent) Post

func (s *Agent) Post(targetUrl string) *Agent

func (*Agent) Proxy

func (s *Agent) Proxy(proxyUrl string) *Agent

func (*Agent) Put

func (s *Agent) Put(targetUrl string) *Agent

func (*Agent) Query

func (s *Agent) Query(content interface{}) *Agent

func (*Agent) RedirectPolicy

func (s *Agent) RedirectPolicy(policy func(req Request, via []Request) error) *Agent

func (*Agent) Retry

func (s *Agent) Retry(retryerCount int, retryerTime time.Duration, statusCode ...int) *Agent

func (*Agent) Send

func (s *Agent) Send(content interface{}) *Agent

func (*Agent) SendFile

func (s *Agent) SendFile(file interface{}, args ...interface{}) *Agent

func (*Agent) SendMap

func (s *Agent) SendMap(content interface{}) *Agent

func (*Agent) SendSlice

func (s *Agent) SendSlice(content []interface{}) *Agent

func (*Agent) SendString

func (s *Agent) SendString(content string) *Agent

func (*Agent) SendStruct

func (s *Agent) SendStruct(content interface{}) *Agent

func (*Agent) Set

func (s *Agent) Set(param string, value string) *Agent

func (*Agent) SetBasicAuth

func (s *Agent) SetBasicAuth(username string, password string) *Agent

func (*Agent) SetCurlCommand

func (s *Agent) SetCurlCommand(enable bool) *Agent

func (*Agent) SetDebug

func (s *Agent) SetDebug(enable bool) *Agent

func (*Agent) SetDoNotClearSuperAgent

func (s *Agent) SetDoNotClearSuperAgent(enable bool) *Agent

func (*Agent) SetLogger

func (s *Agent) SetLogger(logger Logger) *Agent

func (*Agent) TLSClientConfig

func (s *Agent) TLSClientConfig(config *tls.Config) *Agent

func (*Agent) Timeout

func (s *Agent) Timeout(timeout time.Duration) *Agent

func (*Agent) Type

func (s *Agent) Type(typeStr string) *Agent

type File

type File struct {
	Filename  string
	Fieldname string
	Data      []byte
}

type Logger

type Logger interface {
	SetPrefix(string)
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

type Request

type Request *http.Request

type Response

type Response *http.Response

Jump to

Keyboard shortcuts

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