| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package productv1connect |
| 6 |
|
| 7 |
import ( |
| 8 |
connect "connectrpc.com/connect" |
| 9 |
context "context" |
| 10 |
errors "errors" |
| 11 |
v1 "github.com/humanlogio/api/go/svc/feature/v1" |
| 12 |
http "net/http" |
| 13 |
strings "strings" |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
const _ = connect.IsAtLeastVersion1_13_0 |
| 22 |
|
| 23 |
const ( |
| 24 |
|
| 25 |
FeatureServiceName = "svc.product.v1.FeatureService" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
const ( |
| 36 |
|
| 37 |
|
| 38 |
FeatureServiceHasFeatureProcedure = "/svc.product.v1.FeatureService/HasFeature" |
| 39 |
) |
| 40 |
|
| 41 |
|
| 42 |
var ( |
| 43 |
featureServiceServiceDescriptor = v1.File_svc_feature_v1_service_proto.Services().ByName("FeatureService") |
| 44 |
featureServiceHasFeatureMethodDescriptor = featureServiceServiceDescriptor.Methods().ByName("HasFeature") |
| 45 |
) |
| 46 |
|
| 47 |
|
| 48 |
type FeatureServiceClient interface { |
| 49 |
HasFeature(context.Context, *connect.Request[v1.HasFeatureRequest]) (*connect.Response[v1.HasFeatureResponse], error) |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
func NewFeatureServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) FeatureServiceClient { |
| 60 |
baseURL = strings.TrimRight(baseURL, "/") |
| 61 |
return &featureServiceClient{ |
| 62 |
hasFeature: connect.NewClient[v1.HasFeatureRequest, v1.HasFeatureResponse]( |
| 63 |
httpClient, |
| 64 |
baseURL+FeatureServiceHasFeatureProcedure, |
| 65 |
connect.WithSchema(featureServiceHasFeatureMethodDescriptor), |
| 66 |
connect.WithClientOptions(opts...), |
| 67 |
), |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
type featureServiceClient struct { |
| 73 |
hasFeature *connect.Client[v1.HasFeatureRequest, v1.HasFeatureResponse] |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
func (c *featureServiceClient) HasFeature(ctx context.Context, req *connect.Request[v1.HasFeatureRequest]) (*connect.Response[v1.HasFeatureResponse], error) { |
| 78 |
return c.hasFeature.CallUnary(ctx, req) |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
type FeatureServiceHandler interface { |
| 83 |
HasFeature(context.Context, *connect.Request[v1.HasFeatureRequest]) (*connect.Response[v1.HasFeatureResponse], error) |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
func NewFeatureServiceHandler(svc FeatureServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { |
| 92 |
featureServiceHasFeatureHandler := connect.NewUnaryHandler( |
| 93 |
FeatureServiceHasFeatureProcedure, |
| 94 |
svc.HasFeature, |
| 95 |
connect.WithSchema(featureServiceHasFeatureMethodDescriptor), |
| 96 |
connect.WithHandlerOptions(opts...), |
| 97 |
) |
| 98 |
return "/svc.product.v1.FeatureService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 99 |
switch r.URL.Path { |
| 100 |
case FeatureServiceHasFeatureProcedure: |
| 101 |
featureServiceHasFeatureHandler.ServeHTTP(w, r) |
| 102 |
default: |
| 103 |
http.NotFound(w, r) |
| 104 |
} |
| 105 |
}) |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
type UnimplementedFeatureServiceHandler struct{} |
| 110 |
|
| 111 |
func (UnimplementedFeatureServiceHandler) HasFeature(context.Context, *connect.Request[v1.HasFeatureRequest]) (*connect.Response[v1.HasFeatureResponse], error) { |
| 112 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.product.v1.FeatureService.HasFeature is not implemented")) |
| 113 |
} |