network

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartHTTPSererForOneRequest

func StartHTTPSererForOneRequest(port int, callback HandlerFunc)

StartHTTPSererForOneRequest starts a HTTP server to serve only one request. After one request, it shuts itself down.

Types

type Client

type Client interface {
	Get(url string, parameters map[string]string, response interface{}) error
}

Client is the interface to all clients implemented in this package.

type ClientError

type ClientError struct {
	Message string
}

ClientError occurs when an error happened somewhere in any of the client calls. I'm lazy.

func (ClientError) Error

func (e ClientError) Error() string

type HandlerFunc

type HandlerFunc func(*http.Request)

HandlerFunc is the function that will be called when a request lands on the server.

type JSONClient

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

JSONClient is a client with automatic JSON parsing.

func NewJSONClient

func NewJSONClient(options NewClientOptions) *JSONClient

NewJSONClient creates a new JSONClient.

func (*JSONClient) Get

func (c *JSONClient) Get(url string, parameters map[string]string, responseObject interface{}) error

Get request.

func (*JSONClient) Post added in v1.2.0

func (c *JSONClient) Post(
	url string,
	parameters map[string]string,
	requestBody io.Reader,
	responseObject interface{},
	prepareFn func(*http.Request),
) error

Post request.

type NewClientOptions

type NewClientOptions struct {
	Timeout time.Duration
}

NewClientOptions are the default options to create a new Client.

Jump to

Keyboard shortcuts

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