@@ -22,8 +22,8 @@ import (
22
22
23
23
// Response is used for internal request response (for user message and error message)
24
24
type Response struct {
25
- Err string `json:"err"` // server-side error log message, it won't be exposed to end users
26
- UserMsg string `json:"user_msg"` // meaningful error message for end users, it will be shown in git client's output.
25
+ Err string `json:"err,omitempty "` // server-side error log message, it won't be exposed to end users
26
+ UserMsg string `json:"user_msg,omitempty "` // meaningful error message for end users, it will be shown in git client's output.
27
27
}
28
28
29
29
func getClientIP () string {
@@ -34,7 +34,7 @@ func getClientIP() string {
34
34
return strings .Fields (sshConnEnv )[0 ]
35
35
}
36
36
37
- func newInternalRequest (ctx context.Context , url , method string , postBody ... any ) * httplib.Request {
37
+ func newInternalRequest (ctx context.Context , url , method string , body ... any ) * httplib.Request {
38
38
if setting .InternalToken == "" {
39
39
log .Fatal (`The INTERNAL_TOKEN setting is missing from the configuration file: %q.
40
40
Ensure you are running in the correct environment or set the correct configuration file with -c.` , setting .CustomConf )
@@ -83,14 +83,12 @@ Ensure you are running in the correct environment or set the correct configurati
83
83
})
84
84
}
85
85
86
- if method == "POST" {
86
+ if len ( body ) == 1 {
87
87
req .Header ("Content-Type" , "application/json" )
88
- if len (postBody ) == 1 {
89
- jsonBytes , _ := json .Marshal (postBody [0 ])
90
- req .Body (jsonBytes )
91
- } else if len (postBody ) > 1 {
92
- log .Fatal ("Too many arguments for newInternalRequest" )
93
- }
88
+ jsonBytes , _ := json .Marshal (body [0 ])
89
+ req .Body (jsonBytes )
90
+ } else if len (body ) > 1 {
91
+ log .Fatal ("Too many arguments for newInternalRequest" )
94
92
}
95
93
96
94
req .SetTimeout (10 * time .Second , 60 * time .Second )
0 commit comments