Documentation ¶
Index ¶
- Constants
- Variables
- func WriteError(resp http.ResponseWriter, err error)
- type CreateProductReq
- type CreateProductResp
- func (*CreateProductResp) Descriptor() ([]byte, []int)deprecated
- func (x *CreateProductResp) GetStatus() int32
- func (x *CreateProductResp) GetStatusMessage() string
- func (*CreateProductResp) ProtoMessage()
- func (x *CreateProductResp) ProtoReflect() protoreflect.Message
- func (x *CreateProductResp) Reset()
- func (x *CreateProductResp) String() string
- type GetProductsReq
- func (*GetProductsReq) Descriptor() ([]byte, []int)deprecated
- func (x *GetProductsReq) GetLimit() uint32
- func (x *GetProductsReq) GetPage() uint32
- func (x *GetProductsReq) GetQueryCategory() string
- func (x *GetProductsReq) GetQueryName() string
- func (x *GetProductsReq) GetQuerySku() string
- func (x *GetProductsReq) GetSortby() string
- func (x *GetProductsReq) GetSortdir() string
- func (*GetProductsReq) ProtoMessage()
- func (x *GetProductsReq) ProtoReflect() protoreflect.Message
- func (x *GetProductsReq) Reset()
- func (x *GetProductsReq) String() string
- type GetProductsResp
- func (*GetProductsResp) Descriptor() ([]byte, []int)deprecated
- func (x *GetProductsResp) GetNumResults() uint32
- func (x *GetProductsResp) GetPage() uint32
- func (x *GetProductsResp) GetProducts() *Products
- func (*GetProductsResp) ProtoMessage()
- func (x *GetProductsResp) ProtoReflect() protoreflect.Message
- func (x *GetProductsResp) Reset()
- func (x *GetProductsResp) String() string
- type HTTPClient
- type Product
- func (*Product) Descriptor() ([]byte, []int)deprecated
- func (x *Product) GetCategory() string
- func (x *Product) GetName() string
- func (x *Product) GetSku() string
- func (*Product) ProtoMessage()
- func (x *Product) ProtoReflect() protoreflect.Message
- func (x *Product) Reset()
- func (x *Product) String() string
- type ProductSeller
- type Products
- type TwirpServer
Constants ¶
const ProductSellerPathPrefix = "/twirp/com.leftbyte.productseller.ProductSeller/"
ProductSellerPathPrefix is a convenience constant that may identify URL paths. Should be used with caution, it only matches routes generated by Twirp Go clients, with the default "/twirp" prefix and default CamelCase service and method names. More info: https://twitchtv.github.io/twirp/docs/routing.html
Variables ¶
var File_github_com_leftbyte_product_seller_rpc_productseller_productseller_proto protoreflect.FileDescriptor
Functions ¶
func WriteError ¶
func WriteError(resp http.ResponseWriter, err error)
WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
Types ¶
type CreateProductReq ¶
type CreateProductReq struct { Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"` // contains filtered or unexported fields }
func (*CreateProductReq) Descriptor
deprecated
func (*CreateProductReq) Descriptor() ([]byte, []int)
Deprecated: Use CreateProductReq.ProtoReflect.Descriptor instead.
func (*CreateProductReq) GetProduct ¶
func (x *CreateProductReq) GetProduct() *Product
func (*CreateProductReq) ProtoMessage ¶
func (*CreateProductReq) ProtoMessage()
func (*CreateProductReq) ProtoReflect ¶
func (x *CreateProductReq) ProtoReflect() protoreflect.Message
func (*CreateProductReq) Reset ¶
func (x *CreateProductReq) Reset()
func (*CreateProductReq) String ¶
func (x *CreateProductReq) String() string
type CreateProductResp ¶
type CreateProductResp struct { Status int32 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` // status code: 0 for OK StatusMessage string `protobuf:"bytes,2,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` // more context related to status // contains filtered or unexported fields }
func (*CreateProductResp) Descriptor
deprecated
func (*CreateProductResp) Descriptor() ([]byte, []int)
Deprecated: Use CreateProductResp.ProtoReflect.Descriptor instead.
func (*CreateProductResp) GetStatus ¶
func (x *CreateProductResp) GetStatus() int32
func (*CreateProductResp) GetStatusMessage ¶
func (x *CreateProductResp) GetStatusMessage() string
func (*CreateProductResp) ProtoMessage ¶
func (*CreateProductResp) ProtoMessage()
func (*CreateProductResp) ProtoReflect ¶
func (x *CreateProductResp) ProtoReflect() protoreflect.Message
func (*CreateProductResp) Reset ¶
func (x *CreateProductResp) Reset()
func (*CreateProductResp) String ¶
func (x *CreateProductResp) String() string
type GetProductsReq ¶
type GetProductsReq struct { Page *uint32 `protobuf:"varint,1,opt,name=page,proto3,oneof" json:"page,omitempty"` // default: 1 Limit *uint32 `protobuf:"varint,2,opt,name=limit,proto3,oneof" json:"limit,omitempty"` // default: 25 Sortby *string `protobuf:"bytes,3,opt,name=sortby,proto3,oneof" json:"sortby,omitempty"` // default: None Sortdir *string `protobuf:"bytes,4,opt,name=sortdir,proto3,oneof" json:"sortdir,omitempty"` // default: None QueryName string `protobuf:"bytes,5,opt,name=query_name,json=queryName,proto3" json:"query_name,omitempty"` QueryCategory string `protobuf:"bytes,6,opt,name=query_category,json=queryCategory,proto3" json:"query_category,omitempty"` QuerySku string `protobuf:"bytes,7,opt,name=query_sku,json=querySku,proto3" json:"query_sku,omitempty"` // contains filtered or unexported fields }
func (*GetProductsReq) Descriptor
deprecated
func (*GetProductsReq) Descriptor() ([]byte, []int)
Deprecated: Use GetProductsReq.ProtoReflect.Descriptor instead.
func (*GetProductsReq) GetLimit ¶
func (x *GetProductsReq) GetLimit() uint32
func (*GetProductsReq) GetPage ¶
func (x *GetProductsReq) GetPage() uint32
func (*GetProductsReq) GetQueryCategory ¶
func (x *GetProductsReq) GetQueryCategory() string
func (*GetProductsReq) GetQueryName ¶
func (x *GetProductsReq) GetQueryName() string
func (*GetProductsReq) GetQuerySku ¶
func (x *GetProductsReq) GetQuerySku() string
func (*GetProductsReq) GetSortby ¶
func (x *GetProductsReq) GetSortby() string
func (*GetProductsReq) GetSortdir ¶
func (x *GetProductsReq) GetSortdir() string
func (*GetProductsReq) ProtoMessage ¶
func (*GetProductsReq) ProtoMessage()
func (*GetProductsReq) ProtoReflect ¶
func (x *GetProductsReq) ProtoReflect() protoreflect.Message
func (*GetProductsReq) Reset ¶
func (x *GetProductsReq) Reset()
func (*GetProductsReq) String ¶
func (x *GetProductsReq) String() string
type GetProductsResp ¶
type GetProductsResp struct { Page uint32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` NumResults uint32 `protobuf:"varint,2,opt,name=num_results,json=numResults,proto3" json:"num_results,omitempty"` Products *Products `protobuf:"bytes,3,opt,name=products,proto3" json:"products,omitempty"` // contains filtered or unexported fields }
func (*GetProductsResp) Descriptor
deprecated
func (*GetProductsResp) Descriptor() ([]byte, []int)
Deprecated: Use GetProductsResp.ProtoReflect.Descriptor instead.
func (*GetProductsResp) GetNumResults ¶
func (x *GetProductsResp) GetNumResults() uint32
func (*GetProductsResp) GetPage ¶
func (x *GetProductsResp) GetPage() uint32
func (*GetProductsResp) GetProducts ¶
func (x *GetProductsResp) GetProducts() *Products
func (*GetProductsResp) ProtoMessage ¶
func (*GetProductsResp) ProtoMessage()
func (*GetProductsResp) ProtoReflect ¶
func (x *GetProductsResp) ProtoReflect() protoreflect.Message
func (*GetProductsResp) Reset ¶
func (x *GetProductsResp) Reset()
func (*GetProductsResp) String ¶
func (x *GetProductsResp) String() string
type HTTPClient ¶
HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.
HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.
type Product ¶
type Product struct { Sku string `protobuf:"bytes,1,opt,name=sku,proto3" json:"sku,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Category string `protobuf:"bytes,3,opt,name=category,proto3" json:"category,omitempty"` // contains filtered or unexported fields }
func (*Product) Descriptor
deprecated
func (*Product) GetCategory ¶
func (*Product) ProtoMessage ¶
func (*Product) ProtoMessage()
func (*Product) ProtoReflect ¶
func (x *Product) ProtoReflect() protoreflect.Message
type ProductSeller ¶
type ProductSeller interface { CreateProduct(context.Context, *CreateProductReq) (*CreateProductResp, error) GetProducts(context.Context, *GetProductsReq) (*GetProductsResp, error) }
func NewProductSellerJSONClient ¶
func NewProductSellerJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) ProductSeller
NewProductSellerJSONClient creates a JSON client that implements the ProductSeller interface. It communicates using JSON and can be configured with a custom HTTPClient.
func NewProductSellerProtobufClient ¶
func NewProductSellerProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) ProductSeller
NewProductSellerProtobufClient creates a Protobuf client that implements the ProductSeller interface. It communicates using Protobuf and can be configured with a custom HTTPClient.
type Products ¶
type Products struct { Products []*Product `protobuf:"bytes,1,rep,name=products,proto3" json:"products,omitempty"` // contains filtered or unexported fields }
func (*Products) Descriptor
deprecated
func (*Products) GetProducts ¶
func (*Products) ProtoMessage ¶
func (*Products) ProtoMessage()
func (*Products) ProtoReflect ¶
func (x *Products) ProtoReflect() protoreflect.Message
type TwirpServer ¶
type TwirpServer interface { http.Handler // ServiceDescriptor returns gzipped bytes describing the .proto file that // this service was generated from. Once unzipped, the bytes can be // unmarshalled as a // google.golang.org/protobuf/types/descriptorpb.FileDescriptorProto. // // The returned integer is the index of this particular service within that // FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a // low-level field, expected to be used for reflection. ServiceDescriptor() ([]byte, int) // ProtocGenTwirpVersion is the semantic version string of the version of // twirp used to generate this file. ProtocGenTwirpVersion() string // PathPrefix returns the HTTP URL path prefix for all methods handled by this // service. This can be used with an HTTP mux to route Twirp requests. // The path prefix is in the form: "/<prefix>/<package>.<Service>/" // that is, everything in a Twirp route except for the <Method> at the end. PathPrefix() string }
TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.
func NewProductSellerServer ¶
func NewProductSellerServer(svc ProductSeller, opts ...interface{}) TwirpServer
NewProductSellerServer builds a TwirpServer that can be used as an http.Handler to handle HTTP requests that are routed to the right method in the provided svc implementation. The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).