rest

package
Version: v0.0.0-...-5dc8409 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Name is a constant of type string
	Name = "rest"
	// FailureTypePrefix is a constant of type string
	FailureTypePrefix = "http_"
)

Variables

HTTPFailureTypeMap is a variable of type map

Functions

func NewRestClient

func NewRestClient(options ...microClient.Option) microClient.Client

NewRestClient is a function

Types

type Client

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

Client is a struct

func (*Client) Call

func (c *Client) Call(ctx context.Context, addr string, req *microClient.Request, rsp interface{}, opts ...microClient.CallOption) error

Call is a method which uses client struct object

func (*Client) Do

func (c *Client) Do(req *Request, resp *Response) error

Do is a method

func (*Client) Init

func (c *Client) Init(opts ...microClient.Option) error

Init is a method

func (*Client) NewRequest

func (c *Client) NewRequest(service, schemaID, operationID string, arg interface{}, reqOpts ...microClient.RequestOption) *microClient.Request

NewRequest do not use for rest client.

func (*Client) Options

func (c *Client) Options() microClient.Options

Options is a method which used client struct object

func (*Client) String

func (c *Client) String() string

type Request

type Request struct {
	Req *fasthttp.Request
}

Request is struct

func NewRequest

func NewRequest(method, urlStr string, body ...[]byte) (*Request, error)

NewRequest is a function which creates new request

func (*Request) Close

func (req *Request) Close()

Close is used for closing a request

func (*Request) Copy

func (req *Request) Copy() *Request

Copy is method

func (*Request) GetHeader

func (req *Request) GetHeader(key string) string

GetHeader is a method which gets head from a request

func (*Request) GetMethod

func (req *Request) GetMethod() string

GetMethod is a method

func (*Request) GetRequest

func (req *Request) GetRequest() *fasthttp.Request

GetRequest is a method

func (*Request) GetURI

func (req *Request) GetURI() string

GetURI is a method

func (*Request) SetBody

func (req *Request) SetBody(body []byte)

SetBody is a method used for setting body for a request

func (*Request) SetHeader

func (req *Request) SetHeader(key, value string)

SetHeader is a method used for setting header in a request

func (*Request) SetHeaderCookie

func (req *Request) SetHeaderCookie(key, value string)

SetHeaderCookie is a method used to setting header cookie

func (*Request) SetMethod

func (req *Request) SetMethod(method string)

SetMethod is a method

func (*Request) SetURI

func (req *Request) SetURI(url string)

SetURI sets host for the request.

type Response

type Response struct {
	Resp *fasthttp.Response
}

Response is a struct used for handling response

func NewResponse

func NewResponse() *Response

NewResponse is creating the object of response

func (*Response) Close

func (resp *Response) Close()

Close closes the file descriptor

func (*Response) GetCookie

func (resp *Response) GetCookie(key string) []byte

GetCookie returns response Cookie.

func (*Response) GetHeader

func (resp *Response) GetHeader() []byte

GetHeader get header from the response

func (*Response) GetResponse

func (resp *Response) GetResponse() *fasthttp.Response

GetResponse is a method used to get response

func (*Response) GetStatusCode

func (resp *Response) GetStatusCode() int

GetStatusCode returns response status code.

func (*Response) ReadBody

func (resp *Response) ReadBody() []byte

ReadBody read body from the from the response

func (*Response) SetCookie

func (resp *Response) SetCookie(cookie *fasthttp.Cookie)

SetCookie sets the cookie.

func (*Response) SetStatusCode

func (resp *Response) SetStatusCode(s int)

SetStatusCode sets the status code

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL