reqtango

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 14 Imported by: 2

README

reqtango

A simple wrapper around the built-in Golang net/http library

Import

go get github.com/JustBugLord/reqtango

License

Apache License 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Method

type Method string
const (
	POST   Method = "POST"
	GET    Method = "GET"
	PUT    Method = "PUT"
	PATCH  Method = "PATCH"
	DELETE Method = "DELETE"
)

type Multipart

type Multipart struct {
	ContentType string
	Body        *bytes.Buffer
}

func RawMultipart

func RawMultipart(data map[string]io.Reader) (*Multipart, error)

type MultipartBuilder

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

func NewMultipartBuilder

func NewMultipartBuilder() *MultipartBuilder

func (*MultipartBuilder) AddField

func (m *MultipartBuilder) AddField(fieldName, fieldValue string)

func (*MultipartBuilder) AddFileByPath

func (m *MultipartBuilder) AddFileByPath(fieldName, filePath string)

func (*MultipartBuilder) Build

func (m *MultipartBuilder) Build() (*Multipart, error)

type Record

type Record struct {
	RecordType RecordType
	Value      string
}

type RecordType

type RecordType string
const (
	File RecordType = "file"
	Text RecordType = "text"
)

type RequestBuilder

type RequestBuilder struct {
	DefaultHeaders map[string]string
	*http.Client
}

func NewRequestBuilder

func NewRequestBuilder(defaultHeaders map[string]string) *RequestBuilder

func NewRequestBuilderSimple

func NewRequestBuilderSimple() *RequestBuilder

func (*RequestBuilder) Get

func (b *RequestBuilder) Get(url string, headers ...interface{}) (*Response, error)

func (*RequestBuilder) GetToStruct

func (b *RequestBuilder) GetToStruct(url string, to any, headers ...interface{}) (*Response, error)

func (*RequestBuilder) Post

func (b *RequestBuilder) Post(url, body string, headers ...interface{}) (*Response, error)

func (*RequestBuilder) PostToStruct

func (b *RequestBuilder) PostToStruct(url, body string, to any, headers ...interface{}) (*Response, error)

func (*RequestBuilder) SendRequest

func (b *RequestBuilder) SendRequest(method Method, url string, body io.Reader, to any, headers ...interface{}) (*Response, error)

func (*RequestBuilder) SendRequestRaw

func (b *RequestBuilder) SendRequestRaw(method Method, url string, body io.Reader, headers ...interface{}) (*http.Response, []byte, error)

func (*RequestBuilder) SetHeaders

func (b *RequestBuilder) SetHeaders(headers map[string]string)

func (*RequestBuilder) UploadMultipart

func (b *RequestBuilder) UploadMultipart(method Method, url string, data *Multipart, headers ...interface{}) (*Response, error)

func (*RequestBuilder) UploadMultipartToStruct

func (b *RequestBuilder) UploadMultipartToStruct(method Method, url string, data *Multipart, to any, headers ...interface{}) (*Response, error)

type Response

type Response struct {
	Status     string
	StatusCode int
	Body       []byte
}

Jump to

Keyboard shortcuts

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