rest

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	DoRequest(ctx context.Context, method, url string, headers map[string]string, payload *RequestPayload) (*HttpResponse, error)
	Use(middleware Middleware)
}

type DefaultHttpClient

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

func NewDefaultHttpClient

func NewDefaultHttpClient() *DefaultHttpClient

func (*DefaultHttpClient) DoRequest

func (c *DefaultHttpClient) DoRequest(ctx context.Context, method, url string, headers map[string]string, payload *RequestPayload) (*HttpResponse, error)

func (*DefaultHttpClient) Use

func (c *DefaultHttpClient) Use(middleware Middleware)

type FileField

type FileField struct {
	Filename string    // file name
	Content  io.Reader // file content
}

type HttpResponse

type HttpResponse struct {
	StatusCode  int
	Body        []byte
	Headers     map[string][]string
	ContentType string
}

type Middleware

type Middleware interface {
	Handle(ctx context.Context, req *http.Request, next MiddlewareHandler) (*http.Response, error)
}

type MiddlewareHandler

type MiddlewareHandler func(ctx context.Context, req *http.Request) (*http.Response, error)

type RequestPayload

type RequestPayload struct {
	Body       io.Reader            // request body
	FormFields map[string]string    // form fields
	FileFields map[string]FileField // file fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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