signer

package
v0.0.0-...-f574766 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Signer

type Signer interface {
	SignRequest(r request.Interface, headersToSign []string) (*request.Request, error)
	SignedURLBy(httpMethod, urlToSign string, expires int) (string, error)
	GenerateSignature(r request.Interface, headersToSign []string) string
	CanonicalizeRequest(r request.Interface, headersToSign []string) string
}

Signer is the Escher Signing object interface

Example
package main

import (
	"log"
	"net/http"

	"github.com/EscherAuth/escher/config"
	"github.com/EscherAuth/escher/request"
	"github.com/EscherAuth/escher/signer"
)

func main() error {

	Config, err := config.NewFromENV()

	if err != nil {
		return err
	}

	req, _ := http.NewRequest("GET", "http://example.com/", nil)

	escherRequest, err := request.NewFromHTTPRequest(req)

	if err != nil {
		return err
	}

	signedRequest, err := signer.New(Config).SignRequest(escherRequest, []string{})

	if err != nil {
		return err
	}

	err = signedRequest.UpdateHTTPRequest(req)

	if err != nil {
		return err
	}

	client := &http.Client{}
	resp, _ := client.Do(req)

	log.Println(resp)

	return nil

}
Output:

func New

func New(c config.Config) Signer

New Create a signer object that behaves by the Signer Interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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