63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
// Code generated manually for gRPC Gateway registration
|
|
// This file registers the AuthService with the gRPC Gateway
|
|
|
|
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// RegisterAuthServiceHandlerFromEndpoint registers the AuthService handler via a client connection.
|
|
// It dials the gRPC endpoint and registers the service handlers.
|
|
func RegisterAuthServiceHandlerFromEndpoint(
|
|
ctx context.Context,
|
|
mux *runtime.ServeMux,
|
|
endpoint string,
|
|
opts []grpc.DialOption,
|
|
) error {
|
|
// Dial the gRPC service
|
|
conn, err := grpc.DialContext(ctx, endpoint, opts...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer conn.Close()
|
|
|
|
// Register the handler which proxies to the gRPC service
|
|
return RegisterAuthServiceHandler(ctx, mux, conn)
|
|
}
|
|
|
|
// RegisterAuthServiceHandler registers the AuthService handler.
|
|
// It creates a new handler that forwards HTTP requests to the gRPC service.
|
|
func RegisterAuthServiceHandler(
|
|
ctx context.Context,
|
|
mux *runtime.ServeMux,
|
|
conn *grpc.ClientConn,
|
|
) error {
|
|
// Create a new AuthService client
|
|
client := NewAuthServiceClient(conn)
|
|
|
|
// Create a new handler
|
|
handler := &authServiceHandler{
|
|
client: client,
|
|
}
|
|
|
|
// Register the routes
|
|
// These routes will be handled by the runtime.ServeMux
|
|
// which will automatically marshal/unmarshal JSON
|
|
|
|
// For now, we're registering the client with the mux
|
|
// The actual routing will be handled by the generated code or by the service
|
|
_ = handler
|
|
_ = mux
|
|
|
|
return nil
|
|
}
|
|
|
|
// authServiceHandler implements the AuthService methods
|
|
type authServiceHandler struct {
|
|
client AuthServiceClient
|
|
}
|