model

package
v1.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Slash                = "/"
	HeaderContentTypeKey = "Content-Type"
	JSONContentType      = "application/json"
)

Variables

This section is empty.

Functions

func NormalizeEndpoint

func NormalizeEndpoint(endpoint string, backslash bool) string

normalizeEndpoint Normalize Endpoint considering ending backslash need.

Types

type Request

type Request struct {
	// Endpoint of the HTTP server. It might include a base path.
	Endpoint string
	// Path of the API endpoint. This path is considered with the endpoint to invoke the HTTP server.
	Path string
	// Query parameters
	QueryParams map[string][]string
	// Request headers
	Headers map[string][]string
	// HTTP method
	Method string
	// Request body as slice of bytes
	RequestBody []byte
	// Multipart body
	MultipartBody *bytes.Buffer
	// Username for basic authentication
	Username string
	// Password for basic authentication
	Password string
}

Request information of the Session.

func NewRequest

func NewRequest(
	method, url, endpoint string,
	backslash bool,
) Request

func (*Request) AddAuthorization

func (r *Request) AddAuthorization(apiKey, jwtValue string)

func (*Request) AddBody

func (r *Request) AddBody(message interface{})

func (*Request) AddJSONHeaders

func (r *Request) AddJSONHeaders()

AddJSONHeaders adds json headers to Request if they are null

func (*Request) AddMultipartBody added in v0.18.0

func (r *Request) AddMultipartBody(mBody bytes.Buffer)

func (*Request) AddPath

func (r *Request) AddPath(path string)

func (*Request) AddQueryParams

func (r *Request) AddQueryParams(params map[string][]string)

func (*Request) GetBody added in v0.18.0

func (r *Request) GetBody() io.Reader

func (*Request) SetContentType added in v0.18.0

func (r *Request) SetContentType(contentType string)

type Response

type Response struct {
	// HTTP response
	HTTPResponse *http.Response
	// Response body as slice of bytes
	ResponseBody []byte
}

Response information of the session.

Jump to

Keyboard shortcuts

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