rshttp

package
v0.0.0-...-fc1e0a8 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGet     = "GET"
	MethodHead    = "HEAD"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH"
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
	MethodOptions = "OPTIONS"
	MethodTrace   = "TRACE"

	MIMEApplicationJSON       = "application/json"
	MIMEApplicationJavaScript = "application/javascript"
	MIMEApplicationXML        = "application/xml"
	MIMETextXML               = "text/xml"
	MIMEApplicationForm       = "application/x-www-form-urlencoded"
	MIMEApplicationProtobuf   = "application/protobuf"
	MIMEApplicationMsgpack    = "application/msgpack"
	MIMETextHTML              = "text/html"
	MIMETextPlain             = "text/plain"
	MIMEMultipartForm         = "multipart/form-data"
	MIMEOctetStream           = "application/octet-stream"
)
View Source
const (
	DefaultTimeout = 5 * time.Second
)
View Source
const (
	ErrUnsupportedMethod = rserrors.Error("Unsupported method")
)

Variables

View Source
var (
	MIMEApplicationJSONCharsetUTF8       = appendUTF8IntoMIME(MIMEApplicationJSON)
	MIMEApplicationJavaScriptCharsetUTF8 = appendUTF8IntoMIME(MIMEApplicationJavaScript)
	MIMEApplicationXMLCharsetUTF8        = appendUTF8IntoMIME(MIMEApplicationXML)
	MIMETextXMLCharsetUTF8               = appendUTF8IntoMIME(MIMETextXML)
	MIMETextHTMLCharsetUTF8              = appendUTF8IntoMIME(MIMETextHTML)
	MIMETextPlainCharsetUTF8             = appendUTF8IntoMIME(MIMETextPlain)
)

Functions

This section is empty.

Types

type ContentType

type ContentType string

func (ContentType) GetBodyFromResponse

func (contentType ContentType) GetBodyFromResponse(res *http.Response) (interface{}, error)

func (ContentType) String

func (contentType ContentType) String() string

func (ContentType) Validate

func (contentType ContentType) Validate() error

type EndpointPath

type EndpointPath string

func (EndpointPath) String

func (endpointPath EndpointPath) String() string

func (EndpointPath) Validate

func (endpointPath EndpointPath) Validate() error

type Method

type Method string

func (Method) String

func (method Method) String() string

func (*Method) UnmarshalJSON

func (method *Method) UnmarshalJSON(data []byte) error

func (Method) Validate

func (method Method) Validate() error

type Request

type Request struct {
	Method      string
	RawUrl      string
	Header      req.Header
	Query       req.QueryParam
	ContentType ContentType
	Body        rsjson.MapJson
	Timeout     Timeout
}

type Response

type Response struct {
	StatusCode   int
	ResponseTime int64
	Body         string
}

func Do

func Do(request *Request) (*Response, error)

type Timeout

type Timeout int64

func (Timeout) GetDuration

func (timeout Timeout) GetDuration() time.Duration

Jump to

Keyboard shortcuts

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