@@ -107,16 +107,9 @@ func (s *ApiServer) RpcFuncHttp(w http.ResponseWriter, r *http.Request) {
107
107
}
108
108
109
109
start := time .Now ()
110
- var success bool
110
+
111
111
var recvBytes , sentBytes int
112
112
var err error
113
- var id string
114
-
115
- // After this point the RPC will be captured in metrics.
116
- defer func () {
117
- s .metrics .ApiRpc (id , time .Since (start ), int64 (recvBytes ), int64 (sentBytes ), ! success )
118
- }()
119
-
120
113
// Check the RPC function ID.
121
114
maybeID , ok := mux .Vars (r )["id" ]
122
115
if ! ok || maybeID == "" {
@@ -129,7 +122,8 @@ func (s *ApiServer) RpcFuncHttp(w http.ResponseWriter, r *http.Request) {
129
122
}
130
123
return
131
124
}
132
- id = strings .ToLower (maybeID )
125
+
126
+ id := strings .ToLower (maybeID )
133
127
134
128
// Find the correct RPC function.
135
129
fn := s .runtime .Rpc (id )
@@ -144,6 +138,12 @@ func (s *ApiServer) RpcFuncHttp(w http.ResponseWriter, r *http.Request) {
144
138
return
145
139
}
146
140
141
+ var success bool
142
+ // After this point the RPC will be captured in metrics.
143
+ defer func () {
144
+ s .metrics .ApiRpc (id , time .Since (start ), int64 (recvBytes ), int64 (sentBytes ), ! success )
145
+ }()
146
+
147
147
// Check if we need to mimic existing GRPC Gateway behaviour or expect to receive/send unwrapped data.
148
148
// Any value for this query parameter, including the parameter existing with an empty value, will
149
149
// indicate that raw behaviour is expected.
0 commit comments