Add digest to request

This commit is contained in:
cheddar 2025-02-14 19:41:22 -05:00
parent 4b143a6650
commit b223a25055
No known key found for this signature in database
3 changed files with 16 additions and 4 deletions

17
main.go
View file

@ -9,6 +9,7 @@ import (
"os"
"crispbyte.dev/sig-auth/client"
"github.com/opencontainers/go-digest"
"golang.org/x/crypto/ssh"
)
@ -30,10 +31,18 @@ func main() {
log.Fatal(err)
}
resp, err := client.Post(
"http://localhost:8080/post",
"application/json",
bytes.NewBuffer(json_data))
id := digest.FromBytes(json_data)
req, err := http.NewRequest("POST", "http://localhost:8080/post", bytes.NewBuffer(json_data))
if err != nil {
log.Fatal(err)
}
req.Header.Add("Content-Digest", string(id.Algorithm())+"="+id.Encoded())
req.Header.Add("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)