-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhttp_request.go
More file actions
39 lines (32 loc) · 831 Bytes
/
http_request.go
File metadata and controls
39 lines (32 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package flowablesdk
import (
"encoding/base64"
"fmt"
"time"
"github.com/topology-zero/flowablesdk/pkg/httpclient"
)
func GetRequest(api *Api, params ...any) *httpclient.Request {
url := Configs.Url
if api.Prefix == ProcessPrefix {
url += Configs.ProcessPrefix
} else if api.Prefix == FormPrefix {
url += Configs.FormPrefix
}
url += api.Url
if len(params) > 0 {
url = fmt.Sprintf(url, params...)
}
request := httpclient.NewHttpRequest(
api.Method,
url,
httpclient.WithTimeout(15*time.Second),
httpclient.WithHeader("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(Configs.Username+":"+Configs.Password))),
)
if Configs.RequestDebug {
request.With(httpclient.WithRequestDebug())
}
if Configs.ResponseDebug {
request.With(httpclient.WithResponseDebug())
}
return request
}