gin_httpsigner

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 9 Imported by: 0

README

works with gin-contrib/httpsign

usage

func main() {

	req, err := http.NewRequestWithContext(context.Background(), "POST", requestURL, strings.NewReader(sampleBodyContent))
	if err != nil {
		panic(err)
	}

	s := NewGinHttpSigner(
		httpsign.KeyID("key-id"), // keep it the same with gin middlewares config
		&httpsign.Secret{
			Key:       "key-secret",  // key secret, read it from env
			Algorithm: &crypto.HmacSha512{}, // keep it the same with gin middlewares config
		}, []string{})
	if err := s.SignRequest(req); err != nil {
		panic(err)
	}

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.StatusCode)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GinHttpSigner

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

func NewGinHttpSigner

func NewGinHttpSigner(keyId httpsign.KeyID, secret *httpsign.Secret, headers []string) *GinHttpSigner

func (*GinHttpSigner) GetSignatureHeader

func (singer *GinHttpSigner) GetSignatureHeader(signatureBase64 string) (*SignatureHeader, error)

func (*GinHttpSigner) SignRequest

func (singer *GinHttpSigner) SignRequest(req *http.Request) error

type SignatureHeader

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

SignatureHeader contains basic info signature header

func (*SignatureHeader) String

func (s *SignatureHeader) String() string

Jump to

Keyboard shortcuts

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