File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ func (c *authCache) evict(token, orgName string) {
145145}
146146
147147// moveToEnd moves a key to the end of the LRU order.
148+ // O(n) scan over the order slice; fine for defaultAuthCacheMax (64).
148149// Must be called with c.mu held.
149150func (c * authCache ) moveToEnd (key string ) {
150151 for i , k := range c .order {
Original file line number Diff line number Diff line change 77)
88
99// allowedOriginPattern matches braintrust.dev and braintrustdata.dev origins
10- // including subdomains and preview deployments.
10+ // including subdomains and preview deployments. HTTP is allowed alongside HTTPS
11+ // to support local development proxies.
1112var allowedOriginPattern = regexp .MustCompile (`^https?://([\w-]+\.)*(braintrust|braintrustdata)\.dev$` )
1213
1314var corsAllowHeaders = strings .Join ([]string {
@@ -40,6 +41,7 @@ func corsMiddleware(next http.Handler) http.Handler {
4041 w .Header ().Set ("Access-Control-Expose-Headers" , corsAllowHeaders )
4142 w .Header ().Set ("Access-Control-Allow-Credentials" , "true" )
4243 w .Header ().Set ("Access-Control-Max-Age" , corsMaxAge )
44+ w .Header ().Set ("Vary" , "Origin" )
4345 // Support Chrome Private Network Access
4446 w .Header ().Set ("Access-Control-Allow-Private-Network" , "true" )
4547 }
Original file line number Diff line number Diff line change 66//
77// Example:
88//
9- // srv := server.New(server.WithAddress(":8300"))
10- //
11- // server.Register(srv, "classify",
12- // eval.T(classifyTask),
13- // []eval.Scorer[string, string]{scorer},
14- // server.RegisterOpts{ProjectName: "my-project"},
15- // )
9+ // classify := &eval.Eval[string, string]{
10+ // Name: "classify",
11+ // Task: eval.T(classifyTask),
12+ // Scorers: []eval.Scorer[string, string]{scorer},
13+ // }
1614//
15+ // srv := server.New(server.WithAddress(":8300"))
16+ // server.Register(srv, classify, server.RegisterOpts{})
1717// log.Fatal(srv.Start())
1818package server
1919
@@ -188,14 +188,18 @@ func (s *Server) Shutdown(ctx context.Context) error {
188188 srv := s .httpServer
189189 s .serverMu .Unlock ()
190190
191+ // Drain active requests before closing the default session,
192+ // so in-flight evals using it can complete.
193+ var err error
194+ if srv != nil {
195+ err = srv .Shutdown (ctx )
196+ }
197+
191198 if s .defaultAuth != nil {
192199 s .defaultAuth .session .Close ()
193200 }
194201
195- if srv == nil {
196- return nil
197- }
198- return srv .Shutdown (ctx )
202+ return err
199203}
200204
201205// handleHealth responds to GET / with a health check.
You can’t perform that action at this time.
0 commit comments