presigner

package
v6.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package presigner implements AWS v4 presigner wrapper for AWS IoT websocket connection. This presigner wrapper works around the AWS IoT websocket's problem in presigned URL with SESSION_TOKEN.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Presigner

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

Presigner is an AWS v4 signer wrapper for AWS IoT.

func New

func New(c *aws.Config) *Presigner

New returns new AWS v4 signer wrapper for AWS IoT.

func (*Presigner) PresignWss

func (a *Presigner) PresignWss(ctx context.Context, endpoint string, expire time.Duration, from time.Time) (string, error)

PresignWss generates presigned AWS IoT websocket URL for specified endpoint hostname.

func (*Presigner) PresignWssNow

func (a *Presigner) PresignWssNow(ctx context.Context, endpoint string) (string, error)

PresignWssNow generates presigned AWS IoT websocket URL for specified endpoint hostname. The URL is valid from now until 24 hours later which is the limit of AWS IoT Websocket connection.

Example
ctx := context.TODO()

cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
	panic(err)
}
ps := New(&cfg)
wssURL, err := ps.PresignWssNow(ctx, "test.iot.world-1.amazonaws.com")
if err != nil {
	panic(err)
}
fmt.Printf("%s\n", wssURL)
Output:

Jump to

Keyboard shortcuts

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