client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package client provides a generic client for communicating with Encore Platform API services, both pushing data to them, but also for verifying the authenticity of data pushed to the running app from those services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the underlying raw client for communicating with the Encore Platform services.

It is injected into each service struct by the main [platform] package.

func New

func New(cfg *Config) *Client

func (*Client) SignedPost

func (c *Client) SignedPost(ctx context.Context, path string, object auth.ObjectType, action auth.ActionType, body auth.Payload, response any, additionalAuthContext ...[]byte) error

SignedPost performs a signed POST request to the specified path.

func (*Client) VerifyAndDecodeRequest

func (c *Client) VerifyAndDecodeRequest(req *http.Request, object auth.ObjectType, action auth.ActionType, body auth.Payload, additionalAuthContext ...[]byte) error

VerifyAndDecodeRequest verifies the authenticity of the request and decodes the request into body.

type Config

type Config struct {
	Host          string      // The host to use
	Clock         clock.Clock // The clock to use
	AppSlug       string      // The app slug to use
	EnvName       string      // The environment name to use
	LatestAuthKey auth.Key    // The auth key to use when signing new requests
	AuthKeys      []auth.Key  // All known auth keys (used to verify data sent from the Encore Platform services)
}

Config is the configuration for the client.

Jump to

Keyboard shortcuts

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