Skip to content

Commit 97f3c88

Browse files
committed
inline setupAndRegister
1 parent 24f8552 commit 97f3c88

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

ct_server_gcp/main.go

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,22 @@ func main() {
111111

112112
// Register handlers for all the configured logs using the correct RPC
113113
// client.
114-
// TODO(phboneff): setupAndRegister can probably be inlined / removed later
115-
_, err = setupAndRegister(ctx,
116-
*rpcDeadline,
117-
vCfg,
118-
corsMux,
119-
*maskInternalErrors,
120-
)
114+
opts := sctfe.InstanceOptions{
115+
Validated: vCfg,
116+
Deadline: *rpcDeadline,
117+
MetricFactory: prometheus.MetricFactory{},
118+
RequestLog: new(sctfe.DefaultRequestLog),
119+
MaskInternalErrors: *maskInternalErrors,
120+
CreateStorage: newGCPStorage,
121+
}
122+
123+
inst, err := sctfe.SetUpInstance(ctx, opts)
121124
if err != nil {
122125
klog.Exitf("Failed to set up log instance for %+v: %v", vCfg, err)
123126
}
127+
for path, handler := range inst.Handlers {
128+
corsMux.Handle(path, handler)
129+
}
124130

125131
// Return a 200 on the root, for GCE default health checking :/
126132
corsMux.HandleFunc("/", func(resp http.ResponseWriter, req *http.Request) {
@@ -221,26 +227,6 @@ func awaitSignal(doneFn func()) {
221227
doneFn()
222228
}
223229

224-
func setupAndRegister(ctx context.Context, deadline time.Duration, vCfg *sctfe.ValidatedLogConfig, mux *http.ServeMux, maskInternalErrors bool) (*sctfe.Instance, error) {
225-
opts := sctfe.InstanceOptions{
226-
Validated: vCfg,
227-
Deadline: deadline,
228-
MetricFactory: prometheus.MetricFactory{},
229-
RequestLog: new(sctfe.DefaultRequestLog),
230-
MaskInternalErrors: maskInternalErrors,
231-
CreateStorage: newGCPStorage,
232-
}
233-
234-
inst, err := sctfe.SetUpInstance(ctx, opts)
235-
if err != nil {
236-
return nil, err
237-
}
238-
for path, handler := range inst.Handlers {
239-
mux.Handle(path, handler)
240-
}
241-
return inst, nil
242-
}
243-
244230
func newGCPStorage(ctx context.Context, signer note.Signer) (*sctfe.CTStorage, error) {
245231
gcpCfg := gcpTessera.Config{
246232
ProjectID: *projectID,

0 commit comments

Comments
 (0)