(next func(http.ResponseWriter, *http.Request, *ttnpb.Gateway))
| 74 | } |
| 75 | |
| 76 | func (s *Server) withGateway(next func(http.ResponseWriter, *http.Request, *ttnpb.Gateway)) http.HandlerFunc { |
| 77 | return func(w http.ResponseWriter, r *http.Request) { |
| 78 | ctx := r.Context() |
| 79 | gtwID := gatewayIDFromContext(ctx) |
| 80 | cc, err := s.GetPeerConn(ctx, ttnpb.ClusterRole_ENTITY_REGISTRY, nil) |
| 81 | if err != nil { |
| 82 | webhandlers.Error(w, r, err) |
| 83 | return |
| 84 | } |
| 85 | client := ttnpb.NewGatewayRegistryClient(cc) |
| 86 | gtw, err := client.Get(ctx, &ttnpb.GetGatewayRequest{ |
| 87 | GatewayIds: gtwID, |
| 88 | FieldMask: ttnpb.FieldMask("antennas", "frequency_plan_id", "gateway_server_address"), |
| 89 | }, s.WithClusterAuth()) |
| 90 | if err != nil { |
| 91 | webhandlers.Error(w, r, err) |
| 92 | return |
| 93 | } |
| 94 | next(w, r, gtw) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func (s *Server) makeJSONHandler(f func(context.Context, *ttnpb.Gateway) (any, error)) http.HandlerFunc { |
| 99 | return s.withGateway(func(w http.ResponseWriter, r *http.Request, gtw *ttnpb.Gateway) { |
no test coverage detected