utils

package
v0.0.227 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(signingKey string, userID uint) (string, error)

func HTTPRequest

func HTTPRequest(ctx context.Context, method string, url string, body io.Reader, headers map[string]string) (*http.Response, error)

func Haversine added in v0.0.216

func Haversine(startLat, startLng, endLat, endLng float64) float64

Haversine returns the distance between two GPS coordinates in meters.

func LuhnValid

func LuhnValid(number int) bool

func VerifyDeviceJWT

func VerifyDeviceJWT(did string, signingKey string, tokenString string) error

func VerifyJWT

func VerifyJWT(signingKey string, tokenString string) (uint, error)

Types

type ChannelWatcher added in v0.0.178

type ChannelWatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewChannelWatcher added in v0.0.178

func NewChannelWatcher[T any](ch chan T) *ChannelWatcher[T]

func (*ChannelWatcher[T]) Subscribe added in v0.0.178

func (cw *ChannelWatcher[T]) Subscribe(id string, subscriber func(T))

func (*ChannelWatcher[T]) WatchChannel added in v0.0.178

func (cw *ChannelWatcher[T]) WatchChannel(key func(T) string)

type DeviceJWT

type DeviceJWT struct {
	jwt.RegisteredClaims
	Identity string `json:"identity"`
}

type UserJWT

type UserJWT struct {
	jwt.RegisteredClaims
	Identity uint `json:"identity"`
}

func (UserJWT) GetAudience

func (u UserJWT) GetAudience() (jwt.ClaimStrings, error)

func (UserJWT) GetExpirationTime

func (u UserJWT) GetExpirationTime() (*jwt.NumericDate, error)

func (UserJWT) GetIssuedAt

func (u UserJWT) GetIssuedAt() (*jwt.NumericDate, error)

func (UserJWT) GetIssuer

func (u UserJWT) GetIssuer() (string, error)

func (UserJWT) GetNotBefore

func (u UserJWT) GetNotBefore() (*jwt.NumericDate, error)

func (UserJWT) GetSubject

func (u UserJWT) GetSubject() (string, error)

Jump to

Keyboard shortcuts

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