自动生成 protobuf 代码 (tag: v1.8.0)
This commit is contained in:
@@ -33,6 +33,8 @@ const (
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// AnonymousServiceAuthProcedure is the fully-qualified name of the AnonymousService's Auth RPC.
|
||||
AnonymousServiceAuthProcedure = "/anonymous.v1.AnonymousService/Auth"
|
||||
// AnonymousServiceSendCredentialProcedure is the fully-qualified name of the AnonymousService's
|
||||
// SendCredential RPC.
|
||||
AnonymousServiceSendCredentialProcedure = "/anonymous.v1.AnonymousService/SendCredential"
|
||||
@@ -40,6 +42,7 @@ const (
|
||||
|
||||
// AnonymousServiceClient is a client for the anonymous.v1.AnonymousService service.
|
||||
type AnonymousServiceClient interface {
|
||||
Auth(context.Context, *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error)
|
||||
SendCredential(context.Context, *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error)
|
||||
}
|
||||
|
||||
@@ -54,6 +57,12 @@ func NewAnonymousServiceClient(httpClient connect.HTTPClient, baseURL string, op
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
anonymousServiceMethods := v1.File_anonymous_v1_service_proto.Services().ByName("AnonymousService").Methods()
|
||||
return &anonymousServiceClient{
|
||||
auth: connect.NewClient[v1.AuthRequest, v1.AuthResponse](
|
||||
httpClient,
|
||||
baseURL+AnonymousServiceAuthProcedure,
|
||||
connect.WithSchema(anonymousServiceMethods.ByName("Auth")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
sendCredential: connect.NewClient[v1.SendCredentialRequest, v1.SendCredentialResponse](
|
||||
httpClient,
|
||||
baseURL+AnonymousServiceSendCredentialProcedure,
|
||||
@@ -65,9 +74,15 @@ func NewAnonymousServiceClient(httpClient connect.HTTPClient, baseURL string, op
|
||||
|
||||
// anonymousServiceClient implements AnonymousServiceClient.
|
||||
type anonymousServiceClient struct {
|
||||
auth *connect.Client[v1.AuthRequest, v1.AuthResponse]
|
||||
sendCredential *connect.Client[v1.SendCredentialRequest, v1.SendCredentialResponse]
|
||||
}
|
||||
|
||||
// Auth calls anonymous.v1.AnonymousService.Auth.
|
||||
func (c *anonymousServiceClient) Auth(ctx context.Context, req *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error) {
|
||||
return c.auth.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SendCredential calls anonymous.v1.AnonymousService.SendCredential.
|
||||
func (c *anonymousServiceClient) SendCredential(ctx context.Context, req *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error) {
|
||||
return c.sendCredential.CallUnary(ctx, req)
|
||||
@@ -75,6 +90,7 @@ func (c *anonymousServiceClient) SendCredential(ctx context.Context, req *connec
|
||||
|
||||
// AnonymousServiceHandler is an implementation of the anonymous.v1.AnonymousService service.
|
||||
type AnonymousServiceHandler interface {
|
||||
Auth(context.Context, *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error)
|
||||
SendCredential(context.Context, *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error)
|
||||
}
|
||||
|
||||
@@ -85,6 +101,12 @@ type AnonymousServiceHandler interface {
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewAnonymousServiceHandler(svc AnonymousServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
anonymousServiceMethods := v1.File_anonymous_v1_service_proto.Services().ByName("AnonymousService").Methods()
|
||||
anonymousServiceAuthHandler := connect.NewUnaryHandler(
|
||||
AnonymousServiceAuthProcedure,
|
||||
svc.Auth,
|
||||
connect.WithSchema(anonymousServiceMethods.ByName("Auth")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
anonymousServiceSendCredentialHandler := connect.NewUnaryHandler(
|
||||
AnonymousServiceSendCredentialProcedure,
|
||||
svc.SendCredential,
|
||||
@@ -93,6 +115,8 @@ func NewAnonymousServiceHandler(svc AnonymousServiceHandler, opts ...connect.Han
|
||||
)
|
||||
return "/anonymous.v1.AnonymousService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case AnonymousServiceAuthProcedure:
|
||||
anonymousServiceAuthHandler.ServeHTTP(w, r)
|
||||
case AnonymousServiceSendCredentialProcedure:
|
||||
anonymousServiceSendCredentialHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
@@ -104,6 +128,10 @@ func NewAnonymousServiceHandler(svc AnonymousServiceHandler, opts ...connect.Han
|
||||
// UnimplementedAnonymousServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedAnonymousServiceHandler struct{}
|
||||
|
||||
func (UnimplementedAnonymousServiceHandler) Auth(context.Context, *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("anonymous.v1.AnonymousService.Auth is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAnonymousServiceHandler) SendCredential(context.Context, *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("anonymous.v1.AnonymousService.SendCredential is not implemented"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user