by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 17:19
    mattfenwick commented #329
  • 10:43
    codecov[bot] commented #364
  • 10:40
    codecov[bot] commented #364
  • 10:36
    ervitis opened #365
  • 10:36
    ervitis opened #364
  • Aug 05 13:39
    moorereason commented #361
  • Aug 05 03:38
    codecov[bot] commented #362
  • Aug 05 03:34
    codecov[bot] commented #362
  • Aug 05 03:33
    codecov[bot] commented #362
  • Aug 05 03:33
    codecov[bot] commented #362
  • Aug 05 03:31
    codecov[bot] commented #362
  • Aug 05 03:29
    codecov[bot] commented #362
  • Aug 05 03:29
    moorereason synchronize #362
  • Aug 05 03:28
    codecov[bot] commented #362
  • Aug 05 03:27
    codecov[bot] commented #362
  • Aug 05 03:27
    moorereason synchronize #362
  • Aug 05 03:25
    codecov[bot] commented #362
  • Aug 05 03:21
    moorereason ready_for_review #362
  • Aug 05 03:21
    codecov[bot] commented #362
  • Aug 05 03:21
    moorereason synchronize #362
Grehgous
@Grehgous
When doing R().SetBody() on []byte it seems to automatically convert to base64 before the Post(). How do I bypass that so it stays in binary format?
Jeevanandam M.
@jeevatkm
@Grehgous Post body is sent as []byte, Resty does change that. However while doing debug log it does coverts to base64.
Jeevanandam M.
@jeevatkm
@/all ANN: go-resty v1.12.0 released!
Jeevanandam M.
@jeevatkm
@/all Resty v2 release plan and Create migration guide from v1 to v2 go-resty/resty#235
Jesse Farinacci
@jessefarinacci
hi :) i've been looking around for an example for resty post with large file data payload, must i really read the entire file into a byte array and then setbody on it? is there some way i can pass in a reference of some sort for resty to nicely stream the data as fast as it can?
Jesse Farinacci
@jessefarinacci
ah, ok, looks like it can take an io.Reader soo... request.SetBody(os.Open("myfile.txt")) may work
thanks for a great library :) appreciate it
Jeevanandam M.
@jeevatkm
@jessefarinacci Thank you :smile: . Yes you have found it correct. io.Reader way to go for your need.
modars
@modars_gitlab
Hi, I want Resty to stop to retry when got a certain types of error.
As far as I know, in Backoff(), Restry just restarts if it got an error from the operation regardless the result of my own retryCondition function.
How can I do this? Thank you
Jeevanandam M.
@jeevatkm
@modars_gitlab Could you please describe certain type of error? I think you could control the retry is needed or not from retry condition func.
modars
@modars_gitlab
@jeevatkm RESTY 2019/04/16 13:00:25 ERROR unexpected end of JSON input, Attempt 1 like this one.
func(r *resty.Response) (needRetry bool, err error) {
    return false, nil
}
I set retry condition like above for testing. This condition was executed but Resty still tried retry
modars
@modars_gitlab
I think because of this (from resty.v1/retry.go Backoff()):
if err == nil && !needsRetry && conditionErr == nil {
Jeevanandam M.
@jeevatkm
@modars_gitlab I think your guess is correct. This scenario is addressed in the Resty v2 implementation. Would you mind trying v2.0.0-rc.2, refer to go-resty/resty#235
modars
@modars_gitlab
@jeevatkm oh i found this pr go-resty/resty#237
I will try v2.0.0-rc.2 Thank you for your help :D
Jeevanandam M.
@jeevatkm
Thank you @modars_gitlab
Luc Stepniewski
@lstep

Hello, I can't find any way to retrieve/fill a stucture with SetResult() when the original JSON object root is a list.
For example, with curl, I get :

# curl -X POST -H Content-Type:application/json -d '{ "command": "version-get" }' http://localhost:8080
[ { "arguments": { "extended": "1.5.0\ntarball\nlinked with:\nlog4cplus 1.1.2\n" }, "result": 0, "text": "1.5.0" } ]

And my code :

type AutoGenerated []struct {
    Arguments struct {
        Extended string `json:"extended"`
    } `json:"arguments"`
    Result int    `json:"result"`
    Text   string `json:"text"`
}

resp, err := resty.R().
        SetBody(`{"command": "version-get"}`).
        SetResult(&AutoGenerated{}).
        Post("http://" + ip + ":" + strconv.Itoa(port))

fmt.Printf("%#v\n", resp.Result().(*AutoGenerated))
I always get an empty result
Jeevanandam M.
@jeevatkm
@lstep I will check and get back to you
Jeevanandam M.
@jeevatkm

ANN: go-resty v2.0.0 released! https://github.com/go-resty/resty

Please check it out and share your feedback :smile:

Jonathan André Schweder
@jaswdr
is there any way to disable x509 certificate verification in the resty instance?
Jeevanandam M.
@jeevatkm
ANN: go-resty v2.1.0 released! https://github.com/go-resty/resty
Phat Nguyen
@fuatto
Hello @jeevatkm, is the issue from @lstep solved?
Jeevanandam M.
@jeevatkm
ANN: go-resty v2.2.0 released! https://github.com/go-resty/resty
Ovidiu-Florin BOGDAN
@madpipeline

Hello world. I'm trying to get a basic REST client running and I'm having issues Decoding the JSON response.

    client := resty.New()
    client.SetBasicAuth(os.Getenv("ARTIFACTORY_USER"), os.Getenv("ARTIFACTORY_PASSWORD"))
    rc := new(artifactory.ReplicationConfiguration)

    req := client.NewRequest()
    req.SetResult(rc)
    resp, _ := req.Get(oldArtyURL + "/api/replications/replicate-test")

    // json.NewDecoder(resp.RawBody()).Decode(rc)

    fmt.Println(resp)
    fmt.Println(rc.URL)
type ReplicationConfiguration struct {
    Username               string `json:"username,omitempty"` // Only in Local Repository
    Password               string `json:"password,omitempty"` // Only in Local Repository
    CronExp                string `json:"cronExp,omitempty"`
    URL                    string `json:"url"` // Only in Local Repository
    RepoKey                string `json:"repoKey,omitempty"`
    SockerTimeoutMillis    int    `json:"socketTimeoutMillis,omitempty"` // Only in Local Repository
    EnableEventReplication bool   `json:"enableEventReplication,omitempty"`
    Enabled                bool   `json:"enabled,omitempty"`
    SyncDeletes            bool   `json:"syncDeletes,omitempty"`
    SyncProperties         bool   `json:"syncProperties,omitempty"`
    SyncStatistics         bool   `json:"syncStatistics,omitempty"`
    PathPrefix             string `json:"pathPrefix,omitempty"`
}

With this I'm getting the responce on, I cna print it, but I get an empty object from decoding the response.

The responce gets printed as a list with one object. Could that affect the decoding?
I've tried decoding it both via the req.SetResult() method and via just using the json.NewDecoder() method. Both result in an empty object. Not sure what I'm doing wrong here
Ovidiu-Florin BOGDAN
@madpipeline
@jeevatkm do you have any suggestions?
Ovidiu-Florin BOGDAN
@madpipeline
I've solved it by sending var rcList []ReplicationConfiguration to the json.Decode and then retrieving the first object
andrewnprice
@andrewnprice
So ummm yeah, "Hi!" I am probably being a complete idiot about this, but could someone please explain how you are supposed to extract data once you get it back from your response? I have been messing with it for the last 6 hours or so, tried looking for examples, and in the source, but I am new to Go and I can't quite figure it out.
I might add, that might be something you want to address in the documentation since it is something that seems to come up from time to time. That said, your primary examples with regards to ingress applications are quite well composed and extremely useful.