@@ -16,13 +16,14 @@ import (
16
16
"reflect"
17
17
"sort"
18
18
"strings"
19
+ "time"
19
20
)
20
21
21
22
type MethodName string
22
23
23
24
type rpcReflectCache struct {
24
25
endpoints map [MethodName ]* methodReflection
25
- rpcs map [MethodName ]* console.ApiEndpointDescriptor
26
+ rpcs map [MethodName ]* console.ApiEndpointDescriptor
26
27
}
27
28
28
29
type methodReflection struct {
@@ -135,10 +136,12 @@ func (s *ConsoleServer) extractApiCallContext(ctx context.Context, in *console.C
135
136
s .logger .Error ("Error looking up user account." , zap .String ("method" , in .Method ), zap .Error (err ))
136
137
return nil , status .Error (codes .Internal , "Error looking up user account." )
137
138
}
138
- callCtx = context .WithValue (context .WithValue (ctx , ctxUserIDKey {}, userUUID ), ctxUsernameKey {}, dbUsername )
139
+ callCtx = context .WithValue (ctx , ctxUserIDKey {}, userUUID )
140
+ callCtx = context .WithValue (callCtx , ctxUsernameKey {}, dbUsername )
141
+ callCtx = context .WithValue (callCtx , ctxVarsKey {}, map [string ]string {})
142
+ callCtx = context .WithValue (callCtx , ctxExpiryKey {}, time .Now ().Add (24 * time .Hour ).Unix ())
139
143
}
140
144
return callCtx , nil
141
-
142
145
}
143
146
144
147
func (s * ConsoleServer ) ListApiEndpoints (ctx context.Context , _ * empty.Empty ) (* console.ApiEndpointList , error ) {
@@ -152,7 +155,7 @@ func (s *ConsoleServer) ListApiEndpoints(ctx context.Context, _ *empty.Empty) (*
152
155
for _ , name := range endpointNames {
153
156
endpoint := s .rpcMethodCache .endpoints [MethodName (name )]
154
157
endpoints = append (endpoints , & console.ApiEndpointDescriptor {
155
- Method : name ,
158
+ Method : name ,
156
159
BodyTemplate : endpoint .requestBodyTemplate ,
157
160
})
158
161
}
@@ -166,7 +169,7 @@ func (s *ConsoleServer) ListApiEndpoints(ctx context.Context, _ *empty.Empty) (*
166
169
for _ , name := range rpcs {
167
170
endpoint := s .rpcMethodCache .rpcs [MethodName (name )]
168
171
rpcEndpoints = append (rpcEndpoints , & console.ApiEndpointDescriptor {
169
- Method : name ,
172
+ Method : name ,
170
173
BodyTemplate : endpoint .BodyTemplate ,
171
174
})
172
175
}
@@ -204,7 +207,7 @@ func (s *ConsoleServer) initRpcMethodCache() error {
204
207
method : method ,
205
208
request : request ,
206
209
requestBodyTemplate : bodyTemplate ,
207
- response : method .Type .In (0 ),
210
+ response : method .Type .In (0 ),
208
211
}
209
212
210
213
}
0 commit comments