| 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/product/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 |
ProductServiceName = "svc.product.v1.ProductService" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
const ( |
| 36 |
|
| 37 |
|
| 38 |
ProductServiceListProductProcedure = "/svc.product.v1.ProductService/ListProduct" |
| 39 |
) |
| 40 |
|
| 41 |
|
| 42 |
type ProductServiceClient interface { |
| 43 |
ListProduct(context.Context, *connect.Request[v1.ListProductRequest]) (*connect.Response[v1.ListProductResponse], error) |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
func NewProductServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ProductServiceClient { |
| 54 |
baseURL = strings.TrimRight(baseURL, "/") |
| 55 |
productServiceMethods := v1.File_svc_product_v1_service_proto.Services().ByName("ProductService").Methods() |
| 56 |
return &productServiceClient{ |
| 57 |
listProduct: connect.NewClient[v1.ListProductRequest, v1.ListProductResponse]( |
| 58 |
httpClient, |
| 59 |
baseURL+ProductServiceListProductProcedure, |
| 60 |
connect.WithSchema(productServiceMethods.ByName("ListProduct")), |
| 61 |
connect.WithClientOptions(opts...), |
| 62 |
), |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
type productServiceClient struct { |
| 68 |
listProduct *connect.Client[v1.ListProductRequest, v1.ListProductResponse] |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
func (c *productServiceClient) ListProduct(ctx context.Context, req *connect.Request[v1.ListProductRequest]) (*connect.Response[v1.ListProductResponse], error) { |
| 73 |
return c.listProduct.CallUnary(ctx, req) |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
type ProductServiceHandler interface { |
| 78 |
ListProduct(context.Context, *connect.Request[v1.ListProductRequest]) (*connect.Response[v1.ListProductResponse], error) |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
func NewProductServiceHandler(svc ProductServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { |
| 87 |
productServiceMethods := v1.File_svc_product_v1_service_proto.Services().ByName("ProductService").Methods() |
| 88 |
productServiceListProductHandler := connect.NewUnaryHandler( |
| 89 |
ProductServiceListProductProcedure, |
| 90 |
svc.ListProduct, |
| 91 |
connect.WithSchema(productServiceMethods.ByName("ListProduct")), |
| 92 |
connect.WithHandlerOptions(opts...), |
| 93 |
) |
| 94 |
return "/svc.product.v1.ProductService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 95 |
switch r.URL.Path { |
| 96 |
case ProductServiceListProductProcedure: |
| 97 |
productServiceListProductHandler.ServeHTTP(w, r) |
| 98 |
default: |
| 99 |
http.NotFound(w, r) |
| 100 |
} |
| 101 |
}) |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
type UnimplementedProductServiceHandler struct{} |
| 106 |
|
| 107 |
func (UnimplementedProductServiceHandler) ListProduct(context.Context, *connect.Request[v1.ListProductRequest]) (*connect.Response[v1.ListProductResponse], error) { |
| 108 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.product.v1.ProductService.ListProduct is not implemented")) |
| 109 |
} |