github.com/d4x1/gin-httpsigner

works with https://github.com/gin-contrib/httpsign


License
MIT
Install
go get github.com/d4x1/gin-httpsigner

Documentation

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)
}