Skip to content

Commit

Permalink
Using pointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Oliver committed May 29, 2023
1 parent da690a8 commit 98d8a18
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (this *model) applyOptions(options []Option) {
}
}
}
func (this model) validate() error {
func (this *model) validate() error {
if len(this.method) == 0 {
return ErrHTTPMethodMissing
} else if this.method != GET && this.method != PUT {
Expand All @@ -71,7 +71,7 @@ func (this model) validate() error {
return nil
}

func (this model) buildRequest() (request *http.Request, err error) {
func (this *model) buildRequest() (request *http.Request, err error) {
if request, err = http.NewRequest(this.method, this.targetURL.String(), this.content); err != nil {
return nil, err
}
Expand All @@ -84,7 +84,7 @@ func (this model) buildRequest() (request *http.Request, err error) {
this.appendHeaders(request)
return request.WithContext(this.context), nil
}
func (this model) authorizeRequest(request *http.Request) error {
func (this *model) authorizeRequest(request *http.Request) error {
if len(this.credentials.BearerToken) > 0 {
request.Header.Set("Authorization", this.credentials.BearerToken)
return nil
Expand All @@ -98,7 +98,7 @@ func (this model) authorizeRequest(request *http.Request) error {
request.URL = this.buildSignedURL(signature)
return nil
}
func (this model) calculateSignature() (string, error) {
func (this *model) calculateSignature() (string, error) {
buffer := bytes.NewBuffer(nil)
this.appendToBuffer(buffer)

Expand All @@ -108,7 +108,7 @@ func (this model) calculateSignature() (string, error) {
return base64.StdEncoding.EncodeToString(signed), nil
}
}
func (this model) appendToBuffer(buffer io.Writer) {
func (this *model) appendToBuffer(buffer io.Writer) {
// https://cloud.google.com/storage/docs/access-control/signed-urls
// https://cloud.google.com/storage/docs/access-control/signing-urls-manually
appendTo(buffer, "%s\n%s\n%s\n%s\n", this.method, this.contentMD5, this.contentType, this.epoch)
Expand All @@ -124,7 +124,7 @@ func appendTo(writer io.Writer, format string, values ...interface{}) {
_, _ = fmt.Fprintf(writer, format, values...)
}

func (this model) buildSignedURL(signature string) *url.URL {
func (this *model) buildSignedURL(signature string) *url.URL {
query := this.targetURL.Query()
query.Set(queryAccessID, this.credentials.AccessID)
query.Set(queryExpires, this.epoch)
Expand All @@ -134,7 +134,7 @@ func (this model) buildSignedURL(signature string) *url.URL {
target.RawQuery = query.Encode()
return &target
}
func (this model) appendHeaders(request *http.Request) {
func (this *model) appendHeaders(request *http.Request) {
headers := request.Header

if this.method == GET {
Expand Down

0 comments on commit 98d8a18

Please sign in to comment.