httprequest

package module
v0.0.0-...-66efcd7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 9 Imported by: 0

README

httprequest

A small http request builder tool inspired by @scraymondjr

Documentation

Index

Constants

View Source
const (
	MIMEApplicationJson = "application/json"
	MIMEApplicationXml  = "application/xml"
	MIMETextXml         = "text/xml"

	HeaderAuthorization = "Authorization"
	HeaderContentType   = "Content-Type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

type RequestBuilder

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

func New

func New(httpMethod, url string, body interface{}) *RequestBuilder

func (*RequestBuilder) AddHeader

func (b *RequestBuilder) AddHeader(key, value string) *RequestBuilder

func (*RequestBuilder) Build

func (b *RequestBuilder) Build(ctx context.Context) (*http.Request, error)

func (*RequestBuilder) ContentType

func (b *RequestBuilder) ContentType(contentType string) *RequestBuilder

func (*RequestBuilder) Do

func (b *RequestBuilder) Do(ctx context.Context, doer Doer, out interface{}) (*http.Response, error)

func (*RequestBuilder) SetHeader

func (b *RequestBuilder) SetHeader(key, value string) *RequestBuilder

func (*RequestBuilder) StatusIn

func (b *RequestBuilder) StatusIn(statuses []int) *RequestBuilder

func (*RequestBuilder) StatusIs

func (b *RequestBuilder) StatusIs(status int) *RequestBuilder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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