Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
add content type
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jul 27, 2019
1 parent a509e8a commit 3c83d7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"encoding/pem"
"errors"
"fmt"
"github.com/lestrrat/go-jwx/jwa"
"github.com/lestrrat/go-jwx/jwt"
"github.com/spf13/viper"
"io"
"io/ioutil"
"log"
Expand All @@ -23,6 +20,10 @@ import (
"strconv"
"strings"
"time"

"github.com/lestrrat/go-jwx/jwa"
"github.com/lestrrat/go-jwx/jwt"
"github.com/spf13/viper"
)

const BaseURL = "https://apigee.googleapis.com/v1/organizations/"
Expand Down Expand Up @@ -197,11 +198,12 @@ func HttpClient(params ...string) error {
var err error

client := &http.Client{}
Info.Println("Connecting to : ", params[0])
Info.Println("Connecting to: ", params[0])

if len(params) == 1 {
req, err = http.NewRequest("GET", params[0], nil)
} else if len(params) == 2 {
Info.Println("Payload: ", params[1])
req, err = http.NewRequest("POST", params[0], bytes.NewBuffer([]byte(params[1])))
} else if len(params) == 3 {
if params[2] == "DELETE" {
Expand All @@ -222,6 +224,7 @@ func HttpClient(params ...string) error {

Info.Println("Setting token : ", RootArgs.Token)
req.Header.Add("Authorization", "Bearer "+RootArgs.Token)
req.Header.Set("Content-Type", "application/json")

resp, err := client.Do(req)

Expand Down

0 comments on commit 3c83d7e

Please sign in to comment.