signature

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 11 Imported by: 2

README

Signature

Golang package for generating/adding the required authentication information to a MYRA API call.

go report card MIT license Go Reference tests

Usage

// Create a new Signature instance using your API credentials provided by Myra Security GmbH and the prepared request
s := signature.New(secret, apiKey, request)

// Append signature to the request and return prepared request
req, err := s.Append()
...`

// OR - return the signature string for own interaction:
t := time.Now().Format(time.RFC3339)
signature, err := s.Signature(t)
...

// OR - just generate and return the SigningString (required for the signature):
signingString := signature.SigningString("content data", "GET", "/en/rapi/...", t)
...

Documentation

Index

Constants

View Source
const (
	// RequestTypeJSON ...
	RequestTypeJSON = "application/json"
)

Variables

This section is empty.

Functions

func SigningString

func SigningString(body string, method string, path string, date string) string

SigningString returns a string for the signature, formatted as described in the Myra API documentation

Types

type Signature

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

Signature holds information about the request, API key, API secret. API key and API secret were provided by Myra Security GmbH

func New

func New(secret string, apikey string, request *http.Request) *Signature

New creates and returns a new Signature instance

func (*Signature) Append

func (s *Signature) Append() (*http.Request, error)

Append builds and adds signature/authentication information to the request and returns the request.

func (*Signature) Signature

func (s *Signature) Signature(date string) (string, error)

Signature builds and returns the signature. date is a time.RFC3339 formatted date string

Jump to

Keyboard shortcuts

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