response

package
v0.0.0-...-f5d52c9 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sugar

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

Sugar response with status code and body data

func New

func New(ctx *xcontext.Context) *Sugar

New new sugared response

func (*Sugar) Body

func (s *Sugar) Body() io.ReadCloser

return respose body

func (*Sugar) Bytes

func (s *Sugar) Bytes() []byte

Bytes read response body as bytes

func (*Sugar) Close

func (s *Sugar) Close() *Sugar

Close close http response body

func (*Sugar) Code

func (s *Sugar) Code() int

Code http status code

func (*Sugar) ContentType

func (s *Sugar) ContentType() string

ContentType read response content type

func (*Sugar) Ctx

func (s *Sugar) Ctx() *xcontext.Context

func (*Sugar) Do

func (s *Sugar) Do() *Sugar

Do do http request with client

func (*Sugar) DoNotRead

func (s *Sugar) DoNotRead() *Sugar

Do do http request with client, do not read to buffer

func (*Sugar) Error

func (s *Sugar) Error() error

func (*Sugar) OK

func (s *Sugar) OK() bool

OK is ok?

func (*Sugar) Response

func (s *Sugar) Response() *http.Response

Response original http response

func (*Sugar) SaveToFile

func (s *Sugar) SaveToFile(fileName string) *Sugar

SaveToFile allows you to download the contents of the response to a file. TODO test

func (*Sugar) Scan

func (s *Sugar) Scan(data interface{}) *Sugar

Scan response body to struct(tag: json/xml)

func (*Sugar) ScanJSON

func (s *Sugar) ScanJSON(userStruct interface{}) *Sugar

ScanJSON is a method that will populate a struct that is provided `userStruct` with the JSON returned within the response body.

func (*Sugar) ScanXML

func (s *Sugar) ScanXML(userStruct interface{}) *Sugar

ScanXML is a method that will populate a struct that is provided `userStruct` with the XML returned within the response body.

func (*Sugar) ScanYAML

func (s *Sugar) ScanYAML(userStruct interface{}) *Sugar

ScanYAML is a method that will populate a struct that is provided `userStruct` with the yaml returned within the response body.

func (*Sugar) String

func (s *Sugar) String() string

String read response body as string

Jump to

Keyboard shortcuts

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