@@ -22,8 +22,8 @@ import (
2222
2323// Response is used for internal request response (for user message and error message)
2424type 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.
2727}
2828
2929func getClientIP () string {
@@ -34,7 +34,7 @@ func getClientIP() string {
3434 return strings .Fields (sshConnEnv )[0 ]
3535}
3636
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 {
3838 if setting .InternalToken == "" {
3939 log .Fatal (`The INTERNAL_TOKEN setting is missing from the configuration file: %q.
4040Ensure 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
8383 })
8484 }
8585
86- if method == "POST" {
86+ if len ( body ) == 1 {
8787 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" )
9492 }
9593
9694 req .SetTimeout (10 * time .Second , 60 * time .Second )
0 commit comments