Documentation
¶
Overview ¶
Package grpcer provide helpers for calling UNO-SOFT gRPC server.
Index ¶
- Constants
- Variables
- func CamelCase(text string) string
- func DialOpts(conf DialConfig) ([]grpc.DialOption, error)
- func NewBasicAuth(username, password string) credentials.PerRPCCredentials
- func NewInsecureBasicAuth(username, password string) credentials.PerRPCCredentials
- func ReadHeadTail(sr *io.SectionReader, maxSize int64) ([]byte, error)
- func SnakeCase(text string) string
- func WithBasicAuth(ctx context.Context, username, password string) context.Context
- type Client
- type DialConfig
- type Field
- type JSONHandler
- type Receiver
- type RequestInfo
- type TempFile
- type XMLRPCHandler
Constants ¶
const BasicAuthKey = contextKey("authorization-basic")
BasicAuthKey is the context key for the Basic Auth.
Variables ¶
var ( DefaultTimeout = 5 * time.Minute MaxLogWidth = 1 << 10 ErrNotFound = errors.New("not found") )
Functions ¶
func DialOpts ¶
func DialOpts(conf DialConfig) ([]grpc.DialOption, error)
DialOpts renders the dial options for calling a gRPC server.
* prefix is inserted before the standard request path - if your server serves on different path. * caFile is the PEM file with the server's CA. * serverHostOverride is to override the CA's host.
func NewBasicAuth ¶
func NewBasicAuth(username, password string) credentials.PerRPCCredentials
NewBasicAuth returns a PerRPCCredentials with the username and password.
func NewInsecureBasicAuth ¶ added in v0.3.0
func NewInsecureBasicAuth(username, password string) credentials.PerRPCCredentials
NewInsecureBasicAuth returns an INSECURE (not requiring secure transport) PerRPCCredentials with the username and password.
func ReadHeadTail ¶ added in v0.10.9
func ReadHeadTail(sr *io.SectionReader, maxSize int64) ([]byte, error)
Types ¶
type Client ¶
type Client interface {
// List the available names
List() []string
// Input returns the input struct for the name.
Input(name string) any
// Call the named function.
Call(name string, ctx context.Context, input any, opts ...grpc.CallOption) (Receiver, error)
}
Client is the client interface for calling a gRPC server.
type DialConfig ¶
type DialConfig struct {
*slog.Logger
// GetLogger func(ctx context.Context) *slog.Logger
PathPrefix string
CAFile string
ServerHostOverride string
Username, Password string
ServiceName, ServiceVersion string
AllowInsecurePasswordTransport bool
}
DialConfig contains the configuration variables.
type Field ¶ added in v0.6.0
func SliceFields ¶ added in v0.6.0
type JSONHandler ¶
type JSONHandler struct {
Client `json:"-"`
*slog.Logger `json:"-"`
GetLogger func(context.Context) *slog.Logger
Timeout time.Duration
MergeStreams bool
}
func (JSONHandler) DecodeRequest ¶ added in v0.6.1
func (h JSONHandler) DecodeRequest(ctx context.Context, r *http.Request) (RequestInfo, any, error)
func (JSONHandler) ServeHTTP ¶
func (h JSONHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RequestInfo ¶ added in v0.6.1
type RequestInfo interface {
Name() string
}
type TempFile ¶ added in v0.6.2
type TempFile struct {
io.WriteCloser
// contains filtered or unexported fields
}
func NewTempFile ¶ added in v0.6.2
NewTempFile creates a new compressed tempfile, that can be read back.
Directories
¶
| Path | Synopsis |
|---|---|
|
protoc-gen-grpc generates a grpcer.Client from the given protoc file.
|
protoc-gen-grpc generates a grpcer.Client from the given protoc file. |