Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ go.work.sum

# env file
.env

.idea
*.iml
15 changes: 10 additions & 5 deletions flowable/rest_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// rest_utils.go centralizes HTTP helpers, default headers, and auth settings used by the package.

// Package-level auth and header configuration
// Package-level auth, header, and HTTP client configuration
var (
AuthUser = ""
AuthPass = ""
Expand All @@ -17,8 +17,15 @@ var (
"Accept": "application/json",
"Content-Type": "application/json",
}
HTTPClient *http.Client = &http.Client{}
)

// SetHTTPClient allows callers to override the HTTP client used for REST requests.
// This is useful for injecting a VCR recorder transport for testing.
func SetHTTPClient(c *http.Client) {
HTTPClient = c
}

// SetAuth allows callers to override the basic auth credentials used for REST requests.
func SetAuth(user, pass string) {
AuthUser = user
Expand Down Expand Up @@ -51,15 +58,14 @@ func prepareRequest(req *http.Request) {

// restGet performs a GET request to the provided full URL and returns status, body bytes, and error.
func restGet(fullURL string) (status int, body []byte, err error) {
client := &http.Client{}
req, err := http.NewRequest("GET", fullURL, nil)
if err != nil {
return -1, nil, err
}

prepareRequest(req)

resp, err := client.Do(req)
resp, err := HTTPClient.Do(req)
if err != nil {
return -1, nil, err
}
Expand All @@ -73,15 +79,14 @@ func restGet(fullURL string) (status int, body []byte, err error) {

// restPost performs a POST request to the provided full URL with the given JSON payload.
func restPost(fullURL string, payload []byte) (status int, body []byte, err error) {
client := &http.Client{}
req, err := http.NewRequest("POST", fullURL, bytes.NewReader(payload))
if err != nil {
return -1, nil, err
}

prepareRequest(req)

resp, err := client.Do(req)
resp, err := HTTPClient.Do(req)
if err != nil {
return -1, nil, err
}
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module github.com/gdharley/flowable-external-client-golang
module github.com/flowable/flowable-external-client-golang

go 1.23.4
go 1.24

require gopkg.in/dnaeon/go-vcr.v4 v4.0.6

require go.yaml.in/yaml/v4 v4.0.0-rc.3 // indirect
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go.yaml.in/yaml/v4 v4.0.0-rc.3 h1:3h1fjsh1CTAPjW7q/EMe+C8shx5d8ctzZTrLcs/j8Go=
go.yaml.in/yaml/v4 v4.0.0-rc.3/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
gopkg.in/dnaeon/go-vcr.v4 v4.0.6 h1:PiJkrakkmzc5s7EfBnZOnyiLwi7o7A9fwPzN0X2uwe0=
gopkg.in/dnaeon/go-vcr.v4 v4.0.6/go.mod h1:sbq5oMEcM4PXngbcNbHhzfCP9OdZodLhrbRYoyg09HY=
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"time"

"github.com/gdharley/flowable-external-client-golang/flowable"
"github.com/gdharley/flowable-external-client-golang/worker"
"github.com/flowable/flowable-external-client-golang/flowable"
"github.com/flowable/flowable-external-client-golang/worker"
)

// Sample main function to start the Flowable external worker subscription
Expand Down
4 changes: 2 additions & 2 deletions test/external_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package worker_test
import (
"testing"

"github.com/gdharley/flowable-external-client-golang/flowable"
"github.com/gdharley/flowable-external-client-golang/worker"
"github.com/flowable/flowable-external-client-golang/flowable"
"github.com/flowable/flowable-external-client-golang/worker"
)

func TestExternalWorkerSuccess(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/getvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/gdharley/flowable-external-client-golang/flowable"
"github.com/flowable/flowable-external-client-golang/flowable"
)

func TestGetVar_String(t *testing.T) {
Expand Down
286 changes: 286 additions & 0 deletions test/integration/cassettes/TestAcquireJobs.yaml

Large diffs are not rendered by default.

393 changes: 393 additions & 0 deletions test/integration/cassettes/TestBPMNErrorWithErrorCode1.yaml

Large diffs are not rendered by default.

393 changes: 393 additions & 0 deletions test/integration/cassettes/TestBPMNErrorWithErrorCode2.yaml

Large diffs are not rendered by default.

393 changes: 393 additions & 0 deletions test/integration/cassettes/TestBPMNErrorWithoutErrorCode.yaml

Large diffs are not rendered by default.

Loading