client

package
v1.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	UserAgentHeaderName = "user-agent"

	DefaultUserAgentName = "OpenCodeProtocol"
)

Variables

This section is empty.

Functions

func GetIPAddr

func GetIPAddr(ctx context.Context) (string, error)

GetIPAddr gets the client's IP address

func InjectLoggingMetadata

func InjectLoggingMetadata(ctx context.Context, log *zap.Logger, userAgentName string) *zap.Logger

InjectLoggingMetadata injects client metadata into a zap logger

func MinVersionStreamServerInterceptor

func MinVersionStreamServerInterceptor(userAgentNames ...string) grpc.StreamServerInterceptor

MinVersionStreamServerInterceptor prevents versions below the minimum version from accessing lower version APIs. The user agent is matched against each of the provided names in order.

func MinVersionUnaryServerInterceptor

func MinVersionUnaryServerInterceptor(userAgentNames ...string) grpc.UnaryServerInterceptor

MinVersionUnaryServerInterceptor prevents versions below the minimum version from accessing outdated APIs. The user agent is matched against each of the provided names in order.

Types

type DeviceType

type DeviceType uint8
const (
	DeviceTypeUnknown DeviceType = iota
	DeviceTypeIOS
	DeviceTypeAndroid
)

func (DeviceType) IsMobile

func (t DeviceType) IsMobile() bool

func (DeviceType) String

func (t DeviceType) String() string

type UserAgent

type UserAgent struct {
	Name       string
	DeviceType DeviceType
	Version    Version
}

func GetUserAgent

func GetUserAgent(ctx context.Context, name string) (*UserAgent, error)

GetUserAgent gets the client user agent value from headers in the provided context

func GetUserAgentByNames added in v1.27.0

func GetUserAgentByNames(ctx context.Context, names ...string) (*UserAgent, error)

GetUserAgentByNames gets the client user agent value from headers in the provided context, trying each name in order and returning the first match.

func (*UserAgent) String

func (ua *UserAgent) String() string

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

func ParseVersion

func ParseVersion(value string) (*Version, error)

func (*Version) Before

func (v *Version) Before(other *Version) bool

func (*Version) GreaterThanOrEqualTo

func (v *Version) GreaterThanOrEqualTo(other *Version) bool

func (*Version) String

func (v *Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL