0 or negative body repeat means stdin for body
parent
b1d98520c3
commit
f782ff175c
13
main.go
13
main.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -16,14 +17,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var bodyRepeat int
|
||||||
var path, host, method, body, headers, brandID, issuer string
|
var path, host, method, body, headers, brandID, issuer string
|
||||||
var ca, cert, key, secret string
|
var ca, cert, key, secret string
|
||||||
var needJWT, verbose bool
|
var needJWT, verbose bool
|
||||||
var timeout time.Duration
|
var timeout time.Duration
|
||||||
flag.StringVar(&method, "method", "get", "method for request")
|
flag.StringVar(&method, "method", "get", "method for request")
|
||||||
flag.StringVar(&path, "path", "fieldsetdefinitions/v1/index/surveys/SV_031sm3MMOPSa8Tz/fieldsets?assumeHasPermission=true", "path for request")
|
flag.StringVar(&path, "path", "fieldsetdefinitions/v1/index/surveys/SV_031sm3MMOPSa8Tz/fieldsets?assumeHasPermission=true", "path for request")
|
||||||
flag.StringVar(&host, "host", "data-platform.service.consul:8080", "host and port for request")
|
flag.StringVar(&host, "host", "data-platform.service.b1-prv.consul:8080", "host and port for request")
|
||||||
flag.StringVar(&body, "body", "", "body for request")
|
flag.StringVar(&body, "body", "", "body for request")
|
||||||
|
flag.IntVar(&bodyRepeat, "bodyrepeat", 1, "repeat body for request")
|
||||||
flag.StringVar(&brandID, "brand", "testencresponse", "brandID for request JWT")
|
flag.StringVar(&brandID, "brand", "testencresponse", "brandID for request JWT")
|
||||||
flag.StringVar(&headers, "headers", "", "headers as k=v,k=v for request")
|
flag.StringVar(&headers, "headers", "", "headers as k=v,k=v for request")
|
||||||
flag.StringVar(&issuer, "issuer", "dataprocessing,responseengine,fieldset-definitions,qualtrics,objectstore,svs,monolith,ex,blixt,null,responseengine", "issuer for jwt")
|
flag.StringVar(&issuer, "issuer", "dataprocessing,responseengine,fieldset-definitions,qualtrics,objectstore,svs,monolith,ex,blixt,null,responseengine", "issuer for jwt")
|
||||||
|
|
@ -41,10 +44,16 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
c := makeClient(timeout, ca, cert, key)
|
c := makeClient(timeout, ca, cert, key)
|
||||||
|
var reqBody io.Reader
|
||||||
|
if bodyRepeat >= 1 {
|
||||||
|
reqBody = strings.NewReader(strings.Repeat(body, bodyRepeat))
|
||||||
|
} else {
|
||||||
|
reqBody = os.Stdin
|
||||||
|
}
|
||||||
req, err := http.NewRequest(
|
req, err := http.NewRequest(
|
||||||
strings.ToUpper(method),
|
strings.ToUpper(method),
|
||||||
host+"/"+strings.Trim(path, "/"),
|
host+"/"+strings.Trim(path, "/"),
|
||||||
strings.NewReader(body),
|
reqBody,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue