diff options
| author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-12-01 15:34:55 +0100 | 
|---|---|---|
| committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-12-01 15:34:55 +0100 | 
| commit | 6cd12911f4d3aa4c6a75c922f9de231e2cf309dd (patch) | |
| tree | a5a39e7e41d4354b8489ae531435c032870ded56 /client | |
| parent | 7fd9d2f727a8acf43bb6312888c1450ed2a1eb60 (diff) | |
attached url method on endpoint type
Diffstat (limited to 'client')
| -rw-r--r-- | client/client.go | 13 | 
1 files changed, 6 insertions, 7 deletions
| diff --git a/client/client.go b/client/client.go index 21be669..6ab654a 100644 --- a/client/client.go +++ b/client/client.go @@ -4,7 +4,6 @@ import (  	"bytes"  	"context"  	"fmt" -	"strings"  	"crypto/ed25519"  	"crypto/tls" @@ -99,7 +98,7 @@ func (c *Client) AddEntry(ctx context.Context, name, checksum []byte) (*stfe.StI  	}  	glog.V(3).Infof("created post data: %s", string(data)) -	url := c.protocol() + strings.Join([]string{c.Log.BaseUrl, string(stfe.EndpointAddEntry)}, "/") +	url := stfe.EndpointAddEntry.Url(c.protocol() + c.Log.BaseUrl)  	req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))  	if err != nil {  		return nil, fmt.Errorf("failed creating http request: %v", err) @@ -126,7 +125,7 @@ func (c *Client) AddEntry(ctx context.Context, name, checksum []byte) (*stfe.StI  // GetSth fetches and verifies the most recent STH.  Safe to use without a  // client chain and corresponding private key.  func (c *Client) GetSth(ctx context.Context) (*stfe.StItem, error) { -	url := c.protocol() + strings.Join([]string{c.Log.BaseUrl, string(stfe.EndpointGetSth)}, "/") +	url := stfe.EndpointGetSth.Url(c.protocol() + c.Log.BaseUrl)  	req, err := http.NewRequest("GET", url, nil)  	if err != nil {  		return nil, fmt.Errorf("failed creating http request: %v", err) @@ -152,7 +151,7 @@ func (c *Client) GetSth(ctx context.Context) (*stfe.StItem, error) {  // GetConsistencyProof fetches and verifies a consistency proof between two  // STHs.  Safe to use without a client chain and corresponding private key.  func (c *Client) GetConsistencyProof(ctx context.Context, first, second *stfe.StItem) (*stfe.StItem, error) { -	url := c.protocol() + strings.Join([]string{c.Log.BaseUrl, string(stfe.EndpointGetConsistencyProof)}, "/") +	url := stfe.EndpointGetConsistencyProof.Url(c.protocol() + c.Log.BaseUrl)  	req, err := http.NewRequest("GET", url, nil)  	if err != nil {  		return nil, fmt.Errorf("failed creating http request: %v", err) @@ -181,7 +180,7 @@ func (c *Client) GetConsistencyProof(ctx context.Context, first, second *stfe.St  // STH.  Safe to use without a client chain and corresponding private key.  func (c *Client) GetProofByHash(ctx context.Context, treeSize uint64, rootHash, leaf []byte) (*stfe.StItem, error) {  	leafHash := rfc6962.DefaultHasher.HashLeaf(leaf) -	url := c.protocol() + strings.Join([]string{c.Log.BaseUrl, string(stfe.EndpointGetProofByHash)}, "/") +	url := stfe.EndpointGetProofByHash.Url(c.protocol() + c.Log.BaseUrl)  	req, err := http.NewRequest("GET", url, nil)  	if err != nil {  		return nil, fmt.Errorf("failed creating http request: %v", err) @@ -214,7 +213,7 @@ func (c *Client) GetProofByHash(ctx context.Context, treeSize uint64, rootHash,  // Note that a certificate chain is considered valid if it is chained correctly.  // In other words, the caller may want to check whether the anchor is trusted.  func (c *Client) GetEntries(ctx context.Context, start, end uint64) ([]*stfe.GetEntryResponse, error) { -	url := c.protocol() + strings.Join([]string{c.Log.BaseUrl, string(stfe.EndpointGetEntries)}, "/") +	url := stfe.EndpointGetEntries.Url(c.protocol() + c.Log.BaseUrl)  	req, err := http.NewRequest("GET", url, nil)  	if err != nil {  		return nil, fmt.Errorf("failed creating http request: %v", err) @@ -252,7 +251,7 @@ func (c *Client) GetEntries(ctx context.Context, start, end uint64) ([]*stfe.Get  // GetAnchors fetches the log's trust anchors.  Safe to use without a client  // chain and corresponding private key.  func (c *Client) GetAnchors(ctx context.Context) ([]*x509.Certificate, error) { -	url := c.protocol() + strings.Join([]string{c.Log.BaseUrl, string(stfe.EndpointGetAnchors)}, "/") +	url := stfe.EndpointGetAnchors.Url(c.protocol() + c.Log.BaseUrl)  	req, err := http.NewRequest("GET", url, nil)  	if err != nil {  		return nil, fmt.Errorf("failed creating http request: %v", err) | 
