httpsimple

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 18 Imported by: 40

Documentation

Index

Constants

View Source
const (
	BodyTypeFile = "file" // Body must be an `io.Reader`. Used for streaming.
	BodyTypeForm = "form"
	BodyTypeJSON = "json"
	BodyTypeXML  = "xml"
)

Variables

This section is empty.

Functions

func DefaultContentTypeBodyType added in v0.64.1

func DefaultContentTypeBodyType(bt string) string

Types

type CLI added in v0.68.0

type CLI struct {
	Method       string   `short:"M" long:"method" description:"Request Method"`
	URL          string   `short:"U" long:"url" description:"Reaquest URL"`
	Header       []string `short:"H" long:"header" description:"Request Header"`
	Body         string   `short:"B" long:"body" description:"Request Body"`
	BodyFilepath string   `short:"F" long:"filepath" description:"Request Body Filepath"`
	BodyJXU      string   `short:"J" long:"jxu" description:"Request Body: JSON Map to URL-encoded"`
}

CLI executes a HTTP request from CLI params. Attribute tags support usage with `github.com/jessevdk/go-flags`.`

func (CLI) Do added in v0.68.0

func (cli CLI) Do(ctx context.Context, w io.Writer) error

func (CLI) Request added in v0.68.0

func (cli CLI) Request() (Request, error)

type Client added in v0.61.0

type Client struct {
	BaseURL    string     // TODO: See if we can do this within Transport: https://gist.github.com/epelc/cc286ad0fd7878fb176a89f2af1177b6
	Query      url.Values // Add If Not Exists
	HTTPClient *http.Client
}

Client provides a simple interface to making HTTP requests using `net/http`.

func NewClient added in v0.62.0

func NewClient(httpClient *http.Client, baseURL string) Client

func (*Client) Do added in v0.61.0

func (sc *Client) Do(ctx context.Context, req Request) (*http.Response, error)

func (*Client) DoUnmarshalJSON added in v0.61.0

func (sc *Client) DoUnmarshalJSON(ctx context.Context, req Request, resBody any) ([]byte, *http.Response, error)

func (*Client) Get added in v0.61.0

func (sc *Client) Get(ctx context.Context, reqURL string) (*http.Response, error)

type Request added in v0.61.0

type Request struct {
	Method        string
	URL           string
	Query         url.Values
	Headers       http.Header
	Body          any
	BodyType      string
	AddXMLDocType bool // only used if `Body` is a struct.
	Cookies       []http.Cookie
}

func NewRequest added in v0.61.0

func NewRequest() Request

func (*Request) BodyBytes added in v0.61.0

func (req *Request) BodyBytes() ([]byte, error)

func (Request) Do added in v0.68.0

func (req Request) Do(ctx context.Context) (*http.Response, error)

func (Request) DoMore added in v0.68.0

func (req Request) DoMore(ctx context.Context) ([]byte, *http.Response, error)

func (*Request) FullURL added in v0.64.1

func (req *Request) FullURL() (*url.URL, error)

func (*Request) HTTPRequest added in v0.64.1

func (req *Request) HTTPRequest(ctx context.Context) (*http.Request, error)

func (*Request) Inflate added in v0.61.0

func (req *Request) Inflate()

Directories

Path Synopsis
cmd
httpreq command

Jump to

Keyboard shortcuts

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