summaryrefslogtreecommitdiffstats
path: root/api/nostr
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-02-13 18:26:53 -0800
committerbndw <ben@bdw.to>2026-02-13 18:26:53 -0800
commit83876eae868bd1e4fb6b9a823a6e8173919f290d (patch)
treef754bcb8b10337db34f6f36ba3d094e53c1bb808 /api/nostr
parent3481c3273f8764bd0a0ab51183dc57f592fb616c (diff)
feat: add Connect (gRPC over HTTP/JSON) support
Connect integration: - Buf Connect codegen added to buf.gen.yaml - Connect handler wraps gRPC server - Serves on same port as WebSocket (:8080) - HTTP/2 with h2c for cleartext HTTP/2 Now serving THREE protocols: 1. gRPC (native) on :50051 - binary, high performance 2. Connect on :8080/nostr.v1.NostrRelay/* - HTTP/JSON, browser compatible 3. WebSocket on :8080/ - Nostr standard protocol All three protocols share: - Same storage layer - Same subscription manager - Same validation logic Browser-friendly! Call gRPC methods with fetch() or curl.
Diffstat (limited to 'api/nostr')
-rw-r--r--api/nostr/v1/nostrv1connect/nostr.connect.go420
1 files changed, 420 insertions, 0 deletions
diff --git a/api/nostr/v1/nostrv1connect/nostr.connect.go b/api/nostr/v1/nostrv1connect/nostr.connect.go
new file mode 100644
index 0000000..fd98039
--- /dev/null
+++ b/api/nostr/v1/nostrv1connect/nostr.connect.go
@@ -0,0 +1,420 @@
1// Code generated by protoc-gen-connect-go. DO NOT EDIT.
2//
3// Source: nostr/v1/nostr.proto
4
5package nostrv1connect
6
7import (
8 connect "connectrpc.com/connect"
9 context "context"
10 errors "errors"
11 http "net/http"
12 v1 "northwest.io/nostr-grpc/api/nostr/v1"
13 strings "strings"
14)
15
16// This is a compile-time assertion to ensure that this generated file and the connect package are
17// compatible. If you get a compiler error that this constant is not defined, this code was
18// generated with a version of connect newer than the one compiled into your binary. You can fix the
19// problem by either regenerating this code with an older version of connect or updating the connect
20// version compiled into your binary.
21const _ = connect.IsAtLeastVersion1_13_0
22
23const (
24 // NostrRelayName is the fully-qualified name of the NostrRelay service.
25 NostrRelayName = "nostr.v1.NostrRelay"
26 // RelayAdminName is the fully-qualified name of the RelayAdmin service.
27 RelayAdminName = "nostr.v1.RelayAdmin"
28)
29
30// These constants are the fully-qualified names of the RPCs defined in this package. They're
31// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
32//
33// Note that these are different from the fully-qualified method names used by
34// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
35// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
36// period.
37const (
38 // NostrRelayPublishEventProcedure is the fully-qualified name of the NostrRelay's PublishEvent RPC.
39 NostrRelayPublishEventProcedure = "/nostr.v1.NostrRelay/PublishEvent"
40 // NostrRelaySubscribeProcedure is the fully-qualified name of the NostrRelay's Subscribe RPC.
41 NostrRelaySubscribeProcedure = "/nostr.v1.NostrRelay/Subscribe"
42 // NostrRelayUnsubscribeProcedure is the fully-qualified name of the NostrRelay's Unsubscribe RPC.
43 NostrRelayUnsubscribeProcedure = "/nostr.v1.NostrRelay/Unsubscribe"
44 // NostrRelayPublishBatchProcedure is the fully-qualified name of the NostrRelay's PublishBatch RPC.
45 NostrRelayPublishBatchProcedure = "/nostr.v1.NostrRelay/PublishBatch"
46 // NostrRelayQueryEventsProcedure is the fully-qualified name of the NostrRelay's QueryEvents RPC.
47 NostrRelayQueryEventsProcedure = "/nostr.v1.NostrRelay/QueryEvents"
48 // NostrRelayCountEventsProcedure is the fully-qualified name of the NostrRelay's CountEvents RPC.
49 NostrRelayCountEventsProcedure = "/nostr.v1.NostrRelay/CountEvents"
50 // RelayAdminGetStatsProcedure is the fully-qualified name of the RelayAdmin's GetStats RPC.
51 RelayAdminGetStatsProcedure = "/nostr.v1.RelayAdmin/GetStats"
52 // RelayAdminGetConnectionsProcedure is the fully-qualified name of the RelayAdmin's GetConnections
53 // RPC.
54 RelayAdminGetConnectionsProcedure = "/nostr.v1.RelayAdmin/GetConnections"
55 // RelayAdminBanPublicKeyProcedure is the fully-qualified name of the RelayAdmin's BanPublicKey RPC.
56 RelayAdminBanPublicKeyProcedure = "/nostr.v1.RelayAdmin/BanPublicKey"
57 // RelayAdminGetStorageInfoProcedure is the fully-qualified name of the RelayAdmin's GetStorageInfo
58 // RPC.
59 RelayAdminGetStorageInfoProcedure = "/nostr.v1.RelayAdmin/GetStorageInfo"
60)
61
62// NostrRelayClient is a client for the nostr.v1.NostrRelay service.
63type NostrRelayClient interface {
64 // Publish a single event
65 PublishEvent(context.Context, *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error)
66 // Subscribe to events matching filters (streaming)
67 Subscribe(context.Context, *connect.Request[v1.SubscribeRequest]) (*connect.ServerStreamForClient[v1.Event], error)
68 // Unsubscribe from an active subscription
69 Unsubscribe(context.Context, *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error)
70 // gRPC-specific: batch publish
71 PublishBatch(context.Context, *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error)
72 // gRPC-specific: paginated query (non-streaming)
73 QueryEvents(context.Context, *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error)
74 // Event counts (NIP-45)
75 CountEvents(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error)
76}
77
78// NewNostrRelayClient constructs a client for the nostr.v1.NostrRelay service. By default, it uses
79// the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
80// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
81// connect.WithGRPCWeb() options.
82//
83// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
84// http://api.acme.com or https://acme.com/grpc).
85func NewNostrRelayClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) NostrRelayClient {
86 baseURL = strings.TrimRight(baseURL, "/")
87 nostrRelayMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("NostrRelay").Methods()
88 return &nostrRelayClient{
89 publishEvent: connect.NewClient[v1.PublishEventRequest, v1.PublishEventResponse](
90 httpClient,
91 baseURL+NostrRelayPublishEventProcedure,
92 connect.WithSchema(nostrRelayMethods.ByName("PublishEvent")),
93 connect.WithClientOptions(opts...),
94 ),
95 subscribe: connect.NewClient[v1.SubscribeRequest, v1.Event](
96 httpClient,
97 baseURL+NostrRelaySubscribeProcedure,
98 connect.WithSchema(nostrRelayMethods.ByName("Subscribe")),
99 connect.WithClientOptions(opts...),
100 ),
101 unsubscribe: connect.NewClient[v1.UnsubscribeRequest, v1.Empty](
102 httpClient,
103 baseURL+NostrRelayUnsubscribeProcedure,
104 connect.WithSchema(nostrRelayMethods.ByName("Unsubscribe")),
105 connect.WithClientOptions(opts...),
106 ),
107 publishBatch: connect.NewClient[v1.PublishBatchRequest, v1.PublishBatchResponse](
108 httpClient,
109 baseURL+NostrRelayPublishBatchProcedure,
110 connect.WithSchema(nostrRelayMethods.ByName("PublishBatch")),
111 connect.WithClientOptions(opts...),
112 ),
113 queryEvents: connect.NewClient[v1.QueryRequest, v1.QueryResponse](
114 httpClient,
115 baseURL+NostrRelayQueryEventsProcedure,
116 connect.WithSchema(nostrRelayMethods.ByName("QueryEvents")),
117 connect.WithClientOptions(opts...),
118 ),
119 countEvents: connect.NewClient[v1.CountRequest, v1.CountResponse](
120 httpClient,
121 baseURL+NostrRelayCountEventsProcedure,
122 connect.WithSchema(nostrRelayMethods.ByName("CountEvents")),
123 connect.WithClientOptions(opts...),
124 ),
125 }
126}
127
128// nostrRelayClient implements NostrRelayClient.
129type nostrRelayClient struct {
130 publishEvent *connect.Client[v1.PublishEventRequest, v1.PublishEventResponse]
131 subscribe *connect.Client[v1.SubscribeRequest, v1.Event]
132 unsubscribe *connect.Client[v1.UnsubscribeRequest, v1.Empty]
133 publishBatch *connect.Client[v1.PublishBatchRequest, v1.PublishBatchResponse]
134 queryEvents *connect.Client[v1.QueryRequest, v1.QueryResponse]
135 countEvents *connect.Client[v1.CountRequest, v1.CountResponse]
136}
137
138// PublishEvent calls nostr.v1.NostrRelay.PublishEvent.
139func (c *nostrRelayClient) PublishEvent(ctx context.Context, req *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error) {
140 return c.publishEvent.CallUnary(ctx, req)
141}
142
143// Subscribe calls nostr.v1.NostrRelay.Subscribe.
144func (c *nostrRelayClient) Subscribe(ctx context.Context, req *connect.Request[v1.SubscribeRequest]) (*connect.ServerStreamForClient[v1.Event], error) {
145 return c.subscribe.CallServerStream(ctx, req)
146}
147
148// Unsubscribe calls nostr.v1.NostrRelay.Unsubscribe.
149func (c *nostrRelayClient) Unsubscribe(ctx context.Context, req *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error) {
150 return c.unsubscribe.CallUnary(ctx, req)
151}
152
153// PublishBatch calls nostr.v1.NostrRelay.PublishBatch.
154func (c *nostrRelayClient) PublishBatch(ctx context.Context, req *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error) {
155 return c.publishBatch.CallUnary(ctx, req)
156}
157
158// QueryEvents calls nostr.v1.NostrRelay.QueryEvents.
159func (c *nostrRelayClient) QueryEvents(ctx context.Context, req *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error) {
160 return c.queryEvents.CallUnary(ctx, req)
161}
162
163// CountEvents calls nostr.v1.NostrRelay.CountEvents.
164func (c *nostrRelayClient) CountEvents(ctx context.Context, req *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) {
165 return c.countEvents.CallUnary(ctx, req)
166}
167
168// NostrRelayHandler is an implementation of the nostr.v1.NostrRelay service.
169type NostrRelayHandler interface {
170 // Publish a single event
171 PublishEvent(context.Context, *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error)
172 // Subscribe to events matching filters (streaming)
173 Subscribe(context.Context, *connect.Request[v1.SubscribeRequest], *connect.ServerStream[v1.Event]) error
174 // Unsubscribe from an active subscription
175 Unsubscribe(context.Context, *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error)
176 // gRPC-specific: batch publish
177 PublishBatch(context.Context, *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error)
178 // gRPC-specific: paginated query (non-streaming)
179 QueryEvents(context.Context, *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error)
180 // Event counts (NIP-45)
181 CountEvents(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error)
182}
183
184// NewNostrRelayHandler builds an HTTP handler from the service implementation. It returns the path
185// on which to mount the handler and the handler itself.
186//
187// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
188// and JSON codecs. They also support gzip compression.
189func NewNostrRelayHandler(svc NostrRelayHandler, opts ...connect.HandlerOption) (string, http.Handler) {
190 nostrRelayMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("NostrRelay").Methods()
191 nostrRelayPublishEventHandler := connect.NewUnaryHandler(
192 NostrRelayPublishEventProcedure,
193 svc.PublishEvent,
194 connect.WithSchema(nostrRelayMethods.ByName("PublishEvent")),
195 connect.WithHandlerOptions(opts...),
196 )
197 nostrRelaySubscribeHandler := connect.NewServerStreamHandler(
198 NostrRelaySubscribeProcedure,
199 svc.Subscribe,
200 connect.WithSchema(nostrRelayMethods.ByName("Subscribe")),
201 connect.WithHandlerOptions(opts...),
202 )
203 nostrRelayUnsubscribeHandler := connect.NewUnaryHandler(
204 NostrRelayUnsubscribeProcedure,
205 svc.Unsubscribe,
206 connect.WithSchema(nostrRelayMethods.ByName("Unsubscribe")),
207 connect.WithHandlerOptions(opts...),
208 )
209 nostrRelayPublishBatchHandler := connect.NewUnaryHandler(
210 NostrRelayPublishBatchProcedure,
211 svc.PublishBatch,
212 connect.WithSchema(nostrRelayMethods.ByName("PublishBatch")),
213 connect.WithHandlerOptions(opts...),
214 )
215 nostrRelayQueryEventsHandler := connect.NewUnaryHandler(
216 NostrRelayQueryEventsProcedure,
217 svc.QueryEvents,
218 connect.WithSchema(nostrRelayMethods.ByName("QueryEvents")),
219 connect.WithHandlerOptions(opts...),
220 )
221 nostrRelayCountEventsHandler := connect.NewUnaryHandler(
222 NostrRelayCountEventsProcedure,
223 svc.CountEvents,
224 connect.WithSchema(nostrRelayMethods.ByName("CountEvents")),
225 connect.WithHandlerOptions(opts...),
226 )
227 return "/nostr.v1.NostrRelay/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
228 switch r.URL.Path {
229 case NostrRelayPublishEventProcedure:
230 nostrRelayPublishEventHandler.ServeHTTP(w, r)
231 case NostrRelaySubscribeProcedure:
232 nostrRelaySubscribeHandler.ServeHTTP(w, r)
233 case NostrRelayUnsubscribeProcedure:
234 nostrRelayUnsubscribeHandler.ServeHTTP(w, r)
235 case NostrRelayPublishBatchProcedure:
236 nostrRelayPublishBatchHandler.ServeHTTP(w, r)
237 case NostrRelayQueryEventsProcedure:
238 nostrRelayQueryEventsHandler.ServeHTTP(w, r)
239 case NostrRelayCountEventsProcedure:
240 nostrRelayCountEventsHandler.ServeHTTP(w, r)
241 default:
242 http.NotFound(w, r)
243 }
244 })
245}
246
247// UnimplementedNostrRelayHandler returns CodeUnimplemented from all methods.
248type UnimplementedNostrRelayHandler struct{}
249
250func (UnimplementedNostrRelayHandler) PublishEvent(context.Context, *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error) {
251 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.PublishEvent is not implemented"))
252}
253
254func (UnimplementedNostrRelayHandler) Subscribe(context.Context, *connect.Request[v1.SubscribeRequest], *connect.ServerStream[v1.Event]) error {
255 return connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.Subscribe is not implemented"))
256}
257
258func (UnimplementedNostrRelayHandler) Unsubscribe(context.Context, *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error) {
259 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.Unsubscribe is not implemented"))
260}
261
262func (UnimplementedNostrRelayHandler) PublishBatch(context.Context, *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error) {
263 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.PublishBatch is not implemented"))
264}
265
266func (UnimplementedNostrRelayHandler) QueryEvents(context.Context, *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error) {
267 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.QueryEvents is not implemented"))
268}
269
270func (UnimplementedNostrRelayHandler) CountEvents(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) {
271 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.CountEvents is not implemented"))
272}
273
274// RelayAdminClient is a client for the nostr.v1.RelayAdmin service.
275type RelayAdminClient interface {
276 GetStats(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error)
277 GetConnections(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error)
278 BanPublicKey(context.Context, *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error)
279 GetStorageInfo(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error)
280}
281
282// NewRelayAdminClient constructs a client for the nostr.v1.RelayAdmin service. By default, it uses
283// the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
284// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
285// connect.WithGRPCWeb() options.
286//
287// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
288// http://api.acme.com or https://acme.com/grpc).
289func NewRelayAdminClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) RelayAdminClient {
290 baseURL = strings.TrimRight(baseURL, "/")
291 relayAdminMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("RelayAdmin").Methods()
292 return &relayAdminClient{
293 getStats: connect.NewClient[v1.Empty, v1.RelayStats](
294 httpClient,
295 baseURL+RelayAdminGetStatsProcedure,
296 connect.WithSchema(relayAdminMethods.ByName("GetStats")),
297 connect.WithClientOptions(opts...),
298 ),
299 getConnections: connect.NewClient[v1.Empty, v1.ConnectionList](
300 httpClient,
301 baseURL+RelayAdminGetConnectionsProcedure,
302 connect.WithSchema(relayAdminMethods.ByName("GetConnections")),
303 connect.WithClientOptions(opts...),
304 ),
305 banPublicKey: connect.NewClient[v1.BanRequest, v1.Empty](
306 httpClient,
307 baseURL+RelayAdminBanPublicKeyProcedure,
308 connect.WithSchema(relayAdminMethods.ByName("BanPublicKey")),
309 connect.WithClientOptions(opts...),
310 ),
311 getStorageInfo: connect.NewClient[v1.Empty, v1.StorageStats](
312 httpClient,
313 baseURL+RelayAdminGetStorageInfoProcedure,
314 connect.WithSchema(relayAdminMethods.ByName("GetStorageInfo")),
315 connect.WithClientOptions(opts...),
316 ),
317 }
318}
319
320// relayAdminClient implements RelayAdminClient.
321type relayAdminClient struct {
322 getStats *connect.Client[v1.Empty, v1.RelayStats]
323 getConnections *connect.Client[v1.Empty, v1.ConnectionList]
324 banPublicKey *connect.Client[v1.BanRequest, v1.Empty]
325 getStorageInfo *connect.Client[v1.Empty, v1.StorageStats]
326}
327
328// GetStats calls nostr.v1.RelayAdmin.GetStats.
329func (c *relayAdminClient) GetStats(ctx context.Context, req *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error) {
330 return c.getStats.CallUnary(ctx, req)
331}
332
333// GetConnections calls nostr.v1.RelayAdmin.GetConnections.
334func (c *relayAdminClient) GetConnections(ctx context.Context, req *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error) {
335 return c.getConnections.CallUnary(ctx, req)
336}
337
338// BanPublicKey calls nostr.v1.RelayAdmin.BanPublicKey.
339func (c *relayAdminClient) BanPublicKey(ctx context.Context, req *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error) {
340 return c.banPublicKey.CallUnary(ctx, req)
341}
342
343// GetStorageInfo calls nostr.v1.RelayAdmin.GetStorageInfo.
344func (c *relayAdminClient) GetStorageInfo(ctx context.Context, req *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error) {
345 return c.getStorageInfo.CallUnary(ctx, req)
346}
347
348// RelayAdminHandler is an implementation of the nostr.v1.RelayAdmin service.
349type RelayAdminHandler interface {
350 GetStats(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error)
351 GetConnections(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error)
352 BanPublicKey(context.Context, *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error)
353 GetStorageInfo(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error)
354}
355
356// NewRelayAdminHandler builds an HTTP handler from the service implementation. It returns the path
357// on which to mount the handler and the handler itself.
358//
359// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
360// and JSON codecs. They also support gzip compression.
361func NewRelayAdminHandler(svc RelayAdminHandler, opts ...connect.HandlerOption) (string, http.Handler) {
362 relayAdminMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("RelayAdmin").Methods()
363 relayAdminGetStatsHandler := connect.NewUnaryHandler(
364 RelayAdminGetStatsProcedure,
365 svc.GetStats,
366 connect.WithSchema(relayAdminMethods.ByName("GetStats")),
367 connect.WithHandlerOptions(opts...),
368 )
369 relayAdminGetConnectionsHandler := connect.NewUnaryHandler(
370 RelayAdminGetConnectionsProcedure,
371 svc.GetConnections,
372 connect.WithSchema(relayAdminMethods.ByName("GetConnections")),
373 connect.WithHandlerOptions(opts...),
374 )
375 relayAdminBanPublicKeyHandler := connect.NewUnaryHandler(
376 RelayAdminBanPublicKeyProcedure,
377 svc.BanPublicKey,
378 connect.WithSchema(relayAdminMethods.ByName("BanPublicKey")),
379 connect.WithHandlerOptions(opts...),
380 )
381 relayAdminGetStorageInfoHandler := connect.NewUnaryHandler(
382 RelayAdminGetStorageInfoProcedure,
383 svc.GetStorageInfo,
384 connect.WithSchema(relayAdminMethods.ByName("GetStorageInfo")),
385 connect.WithHandlerOptions(opts...),
386 )
387 return "/nostr.v1.RelayAdmin/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
388 switch r.URL.Path {
389 case RelayAdminGetStatsProcedure:
390 relayAdminGetStatsHandler.ServeHTTP(w, r)
391 case RelayAdminGetConnectionsProcedure:
392 relayAdminGetConnectionsHandler.ServeHTTP(w, r)
393 case RelayAdminBanPublicKeyProcedure:
394 relayAdminBanPublicKeyHandler.ServeHTTP(w, r)
395 case RelayAdminGetStorageInfoProcedure:
396 relayAdminGetStorageInfoHandler.ServeHTTP(w, r)
397 default:
398 http.NotFound(w, r)
399 }
400 })
401}
402
403// UnimplementedRelayAdminHandler returns CodeUnimplemented from all methods.
404type UnimplementedRelayAdminHandler struct{}
405
406func (UnimplementedRelayAdminHandler) GetStats(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error) {
407 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.GetStats is not implemented"))
408}
409
410func (UnimplementedRelayAdminHandler) GetConnections(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error) {
411 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.GetConnections is not implemented"))
412}
413
414func (UnimplementedRelayAdminHandler) BanPublicKey(context.Context, *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error) {
415 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.BanPublicKey is not implemented"))
416}
417
418func (UnimplementedRelayAdminHandler) GetStorageInfo(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error) {
419 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.GetStorageInfo is not implemented"))
420}