httpegressapi

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package httpegressapi implements the public API of the http.egress.core microservice, including clients and data structures.

The HTTP egress microservice relays HTTP requests to the internet.

Index

Constants

View Source
const Hostname = "http.egress.core"

Hostname is the default hostname of the microservice: http.egress.core.

Variables

View Source
var (
	URLOfMakeRequest = httpx.JoinHostAndPath(Hostname, `:444/make-request`)
)

Fully-qualified URLs of the microservice's endpoints.

Functions

This section is empty.

Types

type Client

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

Client is an interface to calling the endpoints of the http.egress.core microservice. This simple version is for unicast calls.

func NewClient

func NewClient(caller service.Publisher) *Client

NewClient creates a new unicast client to the http.egress.core microservice.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request) (resp *http.Response, err error)

Do makes a request to a URL, respecting the timeout set in the context.

func (*Client) ForHost

func (_c *Client) ForHost(host string) *Client

ForHost replaces the default hostname of this client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) (resp *http.Response, err error)

Get makes a GET request to a URL, respecting the timeout set in the context.

func (*Client) MakeRequest

func (_c *Client) MakeRequest(ctx context.Context, url string, contentType string, body any) (res *http.Response, err error)

MakeRequest proxies a request to a URL and returns the HTTP response, respecting the timeout set in the context. The proxied request is expected to be posted in the body of the request in binary form (RFC7231).

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*Client) MakeRequest_Do

func (_c *Client) MakeRequest_Do(r *http.Request) (res *http.Response, err error)

MakeRequest_Do performs a customized request to the MakeRequest endpoint.

MakeRequest proxies a request to a URL and returns the HTTP response, respecting the timeout set in the context. The proxied request is expected to be posted in the body of the request in binary form (RFC7231).

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) Post

func (c *Client) Post(ctx context.Context, url string, contentType string, body any) (resp *http.Response, err error)

Post makes a POST request to a URL, respecting the timeout set in the context.

type MulticastClient

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

MulticastClient is an interface to calling the endpoints of the http.egress.core microservice. This advanced version is for multicast calls.

func NewMulticastClient

func NewMulticastClient(caller service.Publisher) *MulticastClient

NewMulticastClient creates a new multicast client to the http.egress.core microservice.

func (*MulticastClient) ForHost

func (_c *MulticastClient) ForHost(host string) *MulticastClient

ForHost replaces the default hostname of this client.

func (*MulticastClient) MakeRequest

func (_c *MulticastClient) MakeRequest(ctx context.Context, url string, contentType string, body any) <-chan *pub.Response

MakeRequest proxies a request to a URL and returns the HTTP response, respecting the timeout set in the context. The proxied request is expected to be posted in the body of the request in binary form (RFC7231).

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*MulticastClient) MakeRequest_Do

func (_c *MulticastClient) MakeRequest_Do(ctx context.Context, r *http.Request) <-chan *pub.Response

MakeRequest_Do performs a customized request to the MakeRequest endpoint.

MakeRequest proxies a request to a URL and returns the HTTP response, respecting the timeout set in the context. The proxied request is expected to be posted in the body of the request in binary form (RFC7231).

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

Jump to

Keyboard shortcuts

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