httputil

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSONContentType is the Content-Type header for
	// JSON payloads.
	JSONContentType = "application/json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FormData

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

FormData defines the payload for URL encoded types.

func NewFormData

func NewFormData() *FormData

NewFormData creates a new Form Data Payload type.

func (*FormData) AddBuffer

func (f *FormData) AddBuffer(key, fileName string, buff []byte)

AddBuffer adds a file buffer to the Payload with a filename.

func (*FormData) AddValue

func (f *FormData) AddValue(key, value string)

AddValue adds a key - value string pair to the Payload.

func (*FormData) Buffer

func (f *FormData) Buffer() (*bytes.Buffer, error)

Buffer returns the byte buffer for making the request.

func (*FormData) ContentType

func (f *FormData) ContentType() string

ContentType returns the `Content-Type` header.

func (*FormData) Values

func (f *FormData) Values() map[string]string

Values returns a map of key - value pairs used for testing and debugging.

type JSONData

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

JSONData defines the payload for JSON types.

func NewJSONData

func NewJSONData(obj interface{}) (*JSONData, error)

NewJSONData creates a new JSON Data Payload type. It adds a struct type to the JSON Data payload. Returns an error if the struct could not be marshalled or unmarshalled.

func (*JSONData) Buffer

func (j *JSONData) Buffer() (*bytes.Buffer, error)

Buffer returns the byte buffer for making the request.

func (*JSONData) ContentType

func (j *JSONData) ContentType() string

ContentType returns the `Content-Type` header.

func (*JSONData) Values

func (j *JSONData) Values() map[string]string

Values returns a map of key - value pairs used for testing and debugging.

type Meta

type Meta struct {
	Message string
	ID      string
}

Meta defines the data used for creating a mail.Response.

type Payload

type Payload interface {
	// Buffer returns the byte buffer used for making the
	// HTTP Request
	Buffer() (*bytes.Buffer, error)
	// ContentType returns the `Content-Type` header used for
	// making the HTTP Request
	ContentType() string
	// Values returns a map of key - value pairs used for testing
	// and debugging.
	Values() map[string]string
}

Payload defines the methods used for creating HTTP payload helper.

type Request

type Request struct {
	Method            string
	URL               string
	Headers           map[string]string
	BasicAuthUser     string
	BasicAuthPassword string
}

A Request represents an HTTP request received by a server or to be sent by a client. It is an extension of the std http.Request for Go Mail.

func NewHTTPRequest

func NewHTTPRequest(method, url string) *Request

NewHTTPRequest returns a new Request given a method and URL.

func (*Request) AddHeader

func (r *Request) AddHeader(name, value string)

AddHeader adds the key, value pair to the request headers.

func (*Request) SetBasicAuth

func (r *Request) SetBasicAuth(user, password string)

SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.

With HTTP Basic Authentication the provided username and password are not encrypted.

type Responder

type Responder interface {
	Unmarshal(buf []byte) error
	CheckError(response *http.Response, buf []byte) error
	Meta() Meta
}

Responder defines the methods used for a response back from a mailer's API.

Jump to

Keyboard shortcuts

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