lessrestclient

package
v0.0.131 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AuthTypeNone = iota
	AuthTypeLoginPass
	AuthTypeToken
	AuthTypeBearerToken
	AuthTypeCookieWithCSRFToken
	AuthTypeEDS
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyFormMultipartDataError added in v0.0.23

type BodyFormMultipartDataError struct {
	FormDataError
}

type BodyFormUrlencodedError added in v0.0.23

type BodyFormUrlencodedError struct {
	FormDataError
}

type BodyJSONError added in v0.0.23

type BodyJSONError struct {
	FormDataError
}

type Client

type Client struct {
	URL         string
	ContentType string
	AuthType    int
	Username    string
	Password    string
	Token       string
	BearerToken string
	Cookie      string
	XCSRFToken  string
	SignKeyID   string
	SignBody    string
	// contains filtered or unexported fields
}

func (*Client) CleanAdditionalHeaders added in v0.0.70

func (c *Client) CleanAdditionalHeaders(h map[string]string)

func (*Client) DELETE

func (c *Client) DELETE(
	route string,
	inData interface{},
	outData interface{},
	expectedStatusCode int,
) (statusCode int, respBody []byte, err error)

func (*Client) ErrorRawBody added in v0.0.23

func (c *Client) ErrorRawBody(contentType, rawBody string) string

func (*Client) GET

func (c *Client) GET(
	route string,
	outData interface{},
	expectedStatusCode int,
) (statusCode int, respBody []byte, err error)

func (*Client) GetBodyFormMultipartData added in v0.0.16

func (c *Client) GetBodyFormMultipartData(
	urlAddr, method string,
	inData interface{},
	addHeader *map[string]string,
) (reqBody io.Reader, reqRawBody string, err error)

func (*Client) GetBodyFormUrlencoded added in v0.0.16

func (c *Client) GetBodyFormUrlencoded(
	urlAddr, method string,
	inData interface{},
	addHeader *map[string]string,
) (reqBody io.Reader, reqRawBody string, err error)

func (*Client) GetBodyJSON added in v0.0.16

func (c *Client) GetBodyJSON(
	urlAddr, method string,
	inData interface{},
	addHeader *map[string]string,
) (reqBody io.Reader, reqRawBody string, err error)

func (*Client) GetLastRequestDebugInfo added in v0.0.88

func (c *Client) GetLastRequestDebugInfo() (string, error)

func (*Client) PATCH

func (c *Client) PATCH(
	route string,
	inData interface{},
	outData interface{},
	expectedStatusCode int,
) (statusCode int, respBody []byte, err error)

func (*Client) POST

func (c *Client) POST(
	route string,
	inData interface{},
	outData interface{},
	expectedStatusCode int,
) (statusCode int, respBody []byte, err error)

func (*Client) PUT

func (c *Client) PUT(
	route string,
	inData interface{},
	outData interface{},
	expectedStatusCode int,
) (statusCode int, respBody []byte, err error)

func (*Client) Request

func (c *Client) Request(
	method, route string,
	inData interface{},
	outData interface{},
	expectedStatusCode int,
) (statusCode int, respBody []byte, err error)

func (*Client) SetAdditionalHeaders added in v0.0.70

func (c *Client) SetAdditionalHeaders(h map[string]string)

type ClientError

type ClientError struct {
	URL     string
	Method  string
	RawBody string
	Parent  error
}

func (*ClientError) Error

func (e *ClientError) Error() string

type CreateRequestError

type CreateRequestError struct {
	URL     string
	Method  string
	RawBody string
	Parent  error
}

func (*CreateRequestError) Error

func (e *CreateRequestError) Error() string

type DebugInfo added in v0.0.88

type DebugInfo struct {
	URL          string
	Method       string
	Headers      http.Header
	RequestBody  string
	ResponseBody string
}

type EncoderError

type EncoderError struct {
	URL    string
	Method string
	Data   interface{}
	Parent error
}

func (*EncoderError) Error

func (e *EncoderError) Error() string

type FormDataError added in v0.0.23

type FormDataError struct {
	URL    string
	Method string
	Parent error
}

func (*FormDataError) Error added in v0.0.23

func (e *FormDataError) Error() string

type IsNotPointerError added in v0.0.84

type IsNotPointerError struct {
	Name string
}

func (*IsNotPointerError) Error added in v0.0.84

func (e *IsNotPointerError) Error() string

type LRC

type LRC interface {
	Request(
		method,
		route string,
		inData interface{},
		outData interface{},
		expectedStatusCode int,
	) (statusCode int, respBody []byte, err error)

	GET(
		route string,
		outData interface{},
		expectedStatusCode int,
	) (statusCode int, respBody []byte, err error)

	POST(
		route string,
		inData interface{},
		outData interface{},
		expectedStatusCode int,
	) (statusCode int, respBody []byte, err error)

	PUT(
		route string,
		inData interface{},
		outData interface{},
		expectedStatusCode int,
	) (statusCode int, respBody []byte, err error)

	PATCH(
		route string,
		inData interface{},
		outData interface{},
		expectedStatusCode int,
	) (statusCode int, respBody []byte, err error)

	DELETE(
		route string,
		inData interface{},
		outData interface{},
		expectedStatusCode int,
	) (statusCode int, respBody []byte, err error)

	GetLastRequestDebugInfo() (string, error)
}

func New

func New(c *Client) LRC

type MarshalingError

type MarshalingError struct {
	URL    string
	Method string
	Data   interface{}
	Parent error
}

func (*MarshalingError) Error

func (e *MarshalingError) Error() string

type ReadResponseBodyError

type ReadResponseBodyError struct {
	URL     string
	Method  string
	RawBody string
	Parent  error
}

func (*ReadResponseBodyError) Error

func (e *ReadResponseBodyError) Error() string

type ResponseWithHeaders added in v0.0.85

type ResponseWithHeaders struct {
	Headers http.Header
	OutData interface{}
}

type UnMarshalingError

type UnMarshalingError struct {
	URL     string
	Method  string
	RawBody string
	Parent  error
}

func (*UnMarshalingError) Error

func (e *UnMarshalingError) Error() string

type UnknownAuthTypeError

type UnknownAuthTypeError struct {
	URL    string
	Method string
	Data   interface{}
}

func (*UnknownAuthTypeError) Error

func (e *UnknownAuthTypeError) Error() string

type UnknownContentTypeError

type UnknownContentTypeError struct {
	URL    string
	Method string
	Data   interface{}
}

func (*UnknownContentTypeError) Error

func (e *UnknownContentTypeError) Error() string

type WrongStatusCodeError

type WrongStatusCodeError struct {
	URL             string
	Method          string
	RequestRawBody  string
	ResponseRawBody string
	Expected        int
	Actual          int
}

func (*WrongStatusCodeError) Error

func (e *WrongStatusCodeError) Error() string

Jump to

Keyboard shortcuts

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