httpbody

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFormBody

func NewFormBody(values, files url.Values) (contentType string, bodyReader io.Reader, err error)

NewFormBody returns form request content type and body reader. NOTE:

@values format: <fieldName,[value]>
@files format: <fieldName,[fileName]>

func NewFormBody2

func NewFormBody2(values url.Values, files Files) (contentType string, bodyReader io.Reader)

NewFormBody2 returns form request content type and body reader. NOTE:

@values format: <fieldName,[value]>
@files format: <fieldName,[File]>

func NewJSONBody

func NewJSONBody(v interface{}) (contentType string, bodyReader io.Reader, err error)

NewJSONBody returns JSON request content type and body reader.

func NewXMLBody

func NewXMLBody(v interface{}) (contentType string, bodyReader io.Reader, err error)

NewXMLBody returns XML request content type and body reader.

Types

type File

type File interface {
	// Name returns the name of the file as presented to Open.
	Name() string
	// Read reads up to len(b) bytes from the File.
	// It returns the number of bytes read and any error encountered.
	// At end of file, Read returns 0, io.EOF.
	Read(p []byte) (n int, err error)
}

File interface for form.

func NewFile

func NewFile(name string, bodyReader io.Reader) File

NewFile creates a file for HTTP form.

type Files

type Files map[string][]File

Files maps a string key to a list of files.

Jump to

Keyboard shortcuts

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