contract

package
v0.1.428 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 44 Imported by: 118

Documentation

Index

Constants

View Source
const (
	PathSearch                                 = "search"
	MongoLookupFullDocument  MongoLookupTarget = "fullDocument"
	MongoLookupDocumentKey   MongoLookupTarget = "documentKey"
	MongoLookupOperationType MongoLookupTarget = "operationType"
	TypeArray                AtlasDataType     = "array"
	TypeBoolean              AtlasDataType     = "boolean"
	TypeDate                 AtlasDataType     = "date"
	TypeFacetDate            AtlasDataType     = "dateFacet"
	TypeNumber               AtlasDataType     = "number"
	TypeFacetNumber          AtlasDataType     = "numberFacet"
	TypeGeo                  AtlasDataType     = "geo"
	TypeDocument             AtlasDataType     = "document"
	TypeEmbeddedDoc          AtlasDataType     = "embeddedDocument"
	TypeObjectID             AtlasDataType     = "objectId"
	TypeString               AtlasDataType     = "string"
	TypeFacetString          AtlasDataType     = "stringFacet"
	TypeAutocomplete         AtlasDataType     = "autocomplete"
	TypeToken                AtlasDataType     = "token"
	VerbElemMatch            MongoVerb         = "$elemMatch"
	VerbMatch                MongoVerb         = "$match"
	VerbSkip                 MongoVerb         = "$skip"
	VerbLimit                MongoVerb         = "$limit"
	VerbSort                 MongoVerb         = "$sort"
	VerbCount                MongoVerb         = "$count"
	VerbSearch               MongoVerb         = "$search"
	OpAnd                    BSONOperator      = "$and"
	OpOr                     BSONOperator      = "$or"
	OpNor                    BSONOperator      = "$nor"
	OpGT                     BSONOperator      = "$gt"
	OpGTE                    BSONOperator      = "$gte"
	OpLT                     BSONOperator      = "$lt"
	OpLTE                    BSONOperator      = "$lte"
	OpNE                     BSONOperator      = "$ne"
	OpIn                     BSONOperator      = "$in"
	OpNin                    BSONOperator      = "$nin"
	Ascending                SortDirection     = 1
	Descending               SortDirection     = -1
	MatchAll                 MatchBehavior     = "$all"
	MatchIn                  MatchBehavior     = "$in"
	MatchEqual               MatchBehavior     = "$eq"
)
View Source
const (
	SearchQueryKey   = "q"
	SearchPageKey    = "page"
	SearchPerPageKey = "per_page"
)
View Source
const DefaultIndent = "  "
View Source
const (
	IDKey = "id"
)

Variables

View Source
var SearchRules = QueryParamRules{
	{
		Key:                   SearchQueryKey,
		DefaultValue:          "",
		MultipleValuesAllowed: false,
		Optional:              false,
	},
	{
		Key:                   SearchPageKey,
		DefaultValue:          "",
		MultipleValuesAllowed: false,
		Optional:              false,
	},
	{
		Key:                   SearchPerPageKey,
		DefaultValue:          "",
		MultipleValuesAllowed: false,
		Optional:              false,
	},
}

SearchRules defines validation rules for search queries.

Functions

func ExtractAuthToken added in v0.1.178

func ExtractAuthToken(r *http.Request, opts AuthOptions) (string, error)

ExtractAuthToken extracts the auth token from the request header.

func IDRegistrar added in v0.1.317

func IDRegistrar(reg *bson.Registry)

func ParseOperationResultToSingle added in v0.1.358

func ParseOperationResultToSingle[T any](ctx context.Context, res *OperationResult, recv T, m Marshaler, u Unmarshaler) (T, error)

ParseOperationResultToSingle unmarshals a single item from the operation result into receiver (must be a pointer).

func ParseOperationResultToSlice added in v0.1.358

func ParseOperationResultToSlice[T any](ctx context.Context, res *OperationResult, recv *[]T, m Marshaler, u Unmarshaler) ([]T, error)

ParseOperationResultToSlice unmarshals a slice of items from the operation result into receiver (must be a pointer to a slice).

func ParseOperationResultToSliceDynamic added in v0.1.416

func ParseOperationResultToSliceDynamic(ctx context.Context, res *OperationResult, recv any, m Marshaler, u Unmarshaler) ([]any, error)

ParseOperationResultToSliceDynamic unmarshals a slice of items from the operation result using reflection (receiver must be pointer to a slice of pointers).

Types

type AtlasDataType added in v0.0.5

type AtlasDataType = string

AtlasDataType represents the data types recognized by MongoDB Atlas.

type AtlasIndexes added in v0.1.77

type AtlasIndexes map[string]string

AtlasIndexes is a map of field name to MongoDB Atlas data type.

type Atz added in v0.1.271

type Atz struct {
	Authorize bool
}

Atz controls whether the authorization step should be executed in the handler.

type AuthOption added in v0.1.177

type AuthOption func(*AuthOptions)

func WithAuthorizationHeaderKey added in v0.1.178

func WithAuthorizationHeaderKey(x string) AuthOption

func WithPrefix added in v0.1.177

func WithPrefix(x string) AuthOption

type AuthOptions added in v0.1.177

type AuthOptions struct {
	AuthorizationHeaderKey string
	Prefix                 string
}

AuthOptions holds authentication-related configuration used across multiple systems, including OIDC & Firebase.

func ApplyAuthOptions added in v0.1.177

func ApplyAuthOptions(opts *AuthOptions, modifiers ...AuthOption) AuthOptions

type AuthenticationOperator added in v0.1.178

type AuthenticationOperator interface {
	FirebaseAuthenticator
	OIDCAuthenticator
	AuthenticateWithSecret(ctx context.Context, r *http.Request, opts AuthOptions) error
	AuthenticateAny(ctx context.Context, r *http.Request, opts AuthOptions) error
}

type Authorizable added in v0.1.54

type Authorizable interface {
	Readers() []ID
	Writers() []ID
	Owners() []ID
}

type AuthorizationResult added in v0.1.56

type AuthorizationResult struct {
	UnallowedRecords []ID `json:"unallowed_records"`
}

AuthorizationResult represents an authorization response.

func NewAuthorizationResult added in v0.1.57

func NewAuthorizationResult(opts ...AuthorizationResultOption) *AuthorizationResult

type AuthorizationResultOption added in v0.1.56

type AuthorizationResultOption func(*AuthorizationResult)

func WithUnallowedRecords added in v0.1.233

func WithUnallowedRecords(x []ID) AuthorizationResultOption

type BSONOperator added in v0.0.5

type BSONOperator = string

BSONOperator represents BSON query operators in MongoDB.

type Base64Decoder added in v0.0.5

type Base64Decoder interface {
	DecodeString(enc *base64.Encoding, src string) ([]byte, error)
}

type BasisInt added in v0.1.10

type BasisInt = int

type BasisInt32 added in v0.1.10

type BasisInt32 = int32

type BasisInt64 added in v0.1.10

type BasisInt64 = int64

type BasisOperator added in v0.1.10

type BasisOperator interface {
	BasisIntToMajor(ctx context.Context, b BasisInt, c ConversionFactor) (MajorUnit, error)
	BasisInt32ToMajor(ctx context.Context, b BasisInt32, c ConversionFactor) (MajorUnit, error)
	BasisInt64ToMajor(ctx context.Context, b BasisInt64, c ConversionFactor) (MajorUnit, error)
	MajorToBasis(ctx context.Context, m MajorUnit, c ConversionFactor) (BasisInt64, error)
}

type Bypass added in v0.1.359

type Bypass struct {
	PathID    *string
	Ressource *string
	Compute   bool
}

Bypass allows explicit override of default handler behavior such as skipping path extraction.

type C added in v0.1.416

type C struct {
	Svc        string
	Collection string
	R          *http.Request
	Receiver   any
	Mock       any
}

func (*C) Validate added in v0.1.416

func (o *C) Validate() error

type CacheHit added in v0.0.5

type CacheHit struct {
	V string `json:"v"`
}

CacheHit represents a cache entry that holds a JSON string.

type CacheHitter added in v0.0.5

type CacheHitter interface {
	DecodeHit(ctx context.Context, c CacheHit, dst any) error
	HitFromValue(ctx context.Context, v any) (*CacheHit, error)
}

type CacheID added in v0.0.5

type CacheID string

func (CacheID) String added in v0.0.5

func (c CacheID) String() string

type CacheIdentifier added in v0.0.5

type CacheIdentifier interface {
	CacheID(ctx context.Context, id string) (CacheID, error)
}

type CacheKey added in v0.0.5

type CacheKey struct {
	ID           fmt.Stringer
	Microservice string
	Collection   string
	Multi        *CacheMulti
}

CacheKey represents a cache key. It is used to identify a cache entry & it can be used to generate a matching pattern using wildcards.

func (CacheKey) String added in v0.0.5

func (c CacheKey) String() string

String implements the Stringer interface for Key.

type CacheMulti added in v0.0.5

type CacheMulti struct {
	RawQuery string
}

type CacheOperator added in v0.0.5

type CacheOperator interface {
	CacheIdentifier
	CacheHitter
	Cacher
}

type Cacher added in v0.0.5

type Cacher interface {
	CloserWithCtx
	Get(ctx context.Context, c fmt.Stringer) (*CacheHit, error)
	Set(ctx context.Context, c fmt.Stringer, v CacheHit) error
	BatchGet(ctx context.Context, c []fmt.Stringer) ([]CacheHit, error)
	BatchSet(ctx context.Context, e map[fmt.Stringer]CacheHit) error
	Flush(ctx context.Context, c fmt.Stringer) error
	BatchFlush(ctx context.Context, c []fmt.Stringer) error
	FlushAll(ctx context.Context) error
	Exists(ctx context.Context, c fmt.Stringer) (bool, error)
}

type CertGenerator added in v0.0.5

type CertGenerator interface {
	X509KeyPair(ctx context.Context, certPEMBlock []byte, keyPEMBlock []byte) (tls.Certificate, error)
	AppendCertsFromPEM(ctx context.Context, pool *x509.CertPool, pemCerts []byte) (bool, error)
}

type ChangeEvent added in v0.0.5

type ChangeEvent struct {
	OperationType string `json:"operation_type"`
	FullDocument  any    `json:"full_document"`
}

type Closer added in v0.1.13

type Closer interface {
	Close() error
}

type CloserInOut added in v0.1.381

type CloserInOut interface {
	Close(ctx context.Context, c io.Closer) error
}

type CloserWithCtx added in v0.1.13

type CloserWithCtx interface {
	Close(ctx context.Context) error
}

type ComponentExtractor added in v0.1.10

type ComponentExtractor interface {
	GetComponent(skip int, withFullFn, withFile, withFilePath, withLine bool) string
}

type Conformer added in v0.1.336

type Conformer interface {
	Conform(ctx context.Context, v any) error
}

type ConversionFactor added in v0.1.10

type ConversionFactor = int64

type CreateCollectionsOptions added in v0.1.37

type CreateCollectionsOptions struct {
	Collections []string
}

type CreateIndexesOptions added in v0.1.37

type CreateIndexesOptions struct {
	Collection string
	Indexes    []IndexEntry
}

type CreateSearchIndexesOptions added in v0.1.37

type CreateSearchIndexesOptions struct {
	Collection string
	Indexes    []SearchIndexEntry
}

type DBOperator added in v0.0.5

type DBOperator interface {
	InsertOne(ctx context.Context, opts InsertOneOptions) error
	FindOne(ctx context.Context, opts FindOneOptions) error
	FindMany(ctx context.Context, opts FindManyOptions) ([]any, error)
	ReplaceOne(ctx context.Context, opts ReplaceOneOptions) error
	DeleteOne(ctx context.Context, opts DeleteOneOptions) error
	DeleteMany(ctx context.Context, opts DeleteManyOptions) error
	CloserWithCtx
}

type DateFilterOptions added in v0.0.5

type DateFilterOptions struct {
	YearField  string
	MonthField string
	DayField   string
	RefYear    uint
	RefMonth   uint
	RefDay     uint
	IncludeDay bool
}

type DecodeCursorOptions added in v0.0.5

type DecodeCursorOptions struct {
	Cursor   MongoCursor
	Receiver any
}

type DeleteManyOptions added in v0.0.5

type DeleteManyOptions struct {
	Collection string
	Filter     bson.M
	DeleteAll  bool
}

type DeleteOneHandlerOptions added in v0.1.270

type DeleteOneHandlerOptions struct {
	Atz
	Bypass
}

type DeleteOneOptions added in v0.0.5

type DeleteOneOptions struct {
	Collection string
	IDKey      string
	ID         Identifier
}

type ElemMatchFilterOptions added in v0.0.5

type ElemMatchFilterOptions struct {
	ArrayField string
	Element    any
	PrependStr string
	AppendStr  string
}

type ElemsInArrayFilterOptions added in v0.0.5

type ElemsInArrayFilterOptions struct {
	ArrayField string
	Elements   []any
	PrependStr string
	AppendStr  string
}

type EmailByter added in v0.1.381

type EmailByter interface {
	Bytes(ctx context.Context, e *email.Email) ([]byte, error)
}

type EmailOperator added in v0.1.381

type EmailOperator interface {
	EmailPubSub
	EmailSender
}

type EmailPubSub added in v0.1.381

type EmailPubSub interface {
	NewPubSubEmail(ctx context.Context, t EmailTemplateType, targetLanguage, recipientEmail, recipientUsername string, s EmailSpecifics) (*pubsub.Message, error)
	EncodeSpecifics(ctx context.Context, s EmailSpecifics) (string, error)
	GetSuspensionSentence(ctx context.Context, enumVal int) (EmailSuspensionReason, error)
}

type EmailSender added in v0.1.381

type EmailSender interface {
	SendEmail(ctx context.Context, opts SendEmailOptions) error
}

type EmailSenderInfo added in v0.1.394

type EmailSenderInfo struct {
	Name        string
	FromAddress string
	UserID      string
	ReplyTo     string
}

type EmailSpecifics added in v0.1.396

type EmailSpecifics map[string]string

type EmailSuspensionReason added in v0.1.396

type EmailSuspensionReason = string

type EmailTemplateType added in v0.1.396

type EmailTemplateType = string

type Emailable added in v0.1.385

type Emailable interface {
	Init(ctx context.Context, opts InitOptions) error
	GetSubject() string
	GetTemplateType() EmailTemplateType
}

type Entry added in v0.1.10

type Entry struct {
	Handler HandlerFunc
	Weight  uint
}

Entry maps an HTTP handler to a request weight.

type Env added in v0.1.80

type Env string
const (
	Local   Env = "local"
	Dev     Env = "dev"
	Staging Env = "staging"
	Prod    Env = "prod"
)

func (Env) Validate added in v0.1.126

func (e Env) Validate() error

type EnvInfo added in v0.1.105

type EnvInfo struct {
	E            Env
	L            Level
	Addr         string
	MongoConnStr string
	MongoCluster string
	RedisHost    string
	RedisPort    int
}

func ExtractEnvInfo added in v0.1.106

func ExtractEnvInfo() (*EnvInfo, error)

ExtractEnvInfo returns the current environment information.

type EnvironmentOperator added in v0.1.105

type EnvironmentOperator interface {
	Info(ctx context.Context) (EnvInfo, error)
	RewriteHost(ctx context.Context, u *url.URL) error
}

type FSysFileReader

type FSysFileReader interface {
	FSysReadFile(ctx context.Context, fsys fs.ReadFileFS, path string) ([]byte, error)
}

type FSysOperator added in v0.1.377

type FSysOperator interface {
	FSysFileReader
	FSysSubFSOperator
}

type FSysSubFSOperator added in v0.1.377

type FSysSubFSOperator interface {
	FSysSub(ctx context.Context, fsys fs.FS, path string) (fs.FS, error)
}

type FactoryOperator added in v0.1.10

type FactoryOperator interface {
	New(ctx context.Context, name string) (any, error)
	NewDefault(ctx context.Context, name string) (any, error)
}

type FetchManyOption added in v0.1.416

type FetchManyOption func(*FetchManyOptions)

func WithFetchManyCollection added in v0.1.416

func WithFetchManyCollection(x string) FetchManyOption

func WithFetchManyMock added in v0.1.417

func WithFetchManyMock(x any) FetchManyOption

func WithFetchManyQuery added in v0.1.416

func WithFetchManyQuery(x map[string][]string) FetchManyOption

func WithFetchManyReceiver added in v0.1.416

func WithFetchManyReceiver(x any) FetchManyOption

func WithFetchManyRequest added in v0.1.416

func WithFetchManyRequest(x *http.Request) FetchManyOption

func WithFetchManyService added in v0.1.416

func WithFetchManyService(x string) FetchManyOption

type FetchManyOptions added in v0.1.416

type FetchManyOptions struct {
	C
	Q map[string][]string
}

func ApplyFetchManyOptions added in v0.1.416

func ApplyFetchManyOptions(opts *FetchManyOptions, modifiers ...FetchManyOption) FetchManyOptions

func (*FetchManyOptions) Validate added in v0.1.416

func (o *FetchManyOptions) Validate() error

type FetchOneOption added in v0.1.416

type FetchOneOption func(*FetchOneOptions)

func WithFetchOneCollection added in v0.1.416

func WithFetchOneCollection(x string) FetchOneOption

func WithFetchOneID added in v0.1.416

func WithFetchOneID(x fmt.Stringer) FetchOneOption

func WithFetchOneMock added in v0.1.417

func WithFetchOneMock(x any) FetchOneOption

func WithFetchOneReceiver added in v0.1.416

func WithFetchOneReceiver(x any) FetchOneOption

func WithFetchOneRequest added in v0.1.416

func WithFetchOneRequest(x *http.Request) FetchOneOption

func WithFetchOneService added in v0.1.416

func WithFetchOneService(x string) FetchOneOption

type FetchOneOptions added in v0.1.416

type FetchOneOptions struct {
	C
	ID fmt.Stringer
}

func ApplyFetchOneOptions added in v0.1.416

func ApplyFetchOneOptions(opts *FetchOneOptions, modifiers ...FetchOneOption) FetchOneOptions

func (*FetchOneOptions) Validate added in v0.1.416

func (o *FetchOneOptions) Validate() error

type FetcherOperator added in v0.1.416

type FetcherOperator interface {
	FetchOne(ctx context.Context, opts FetchOneOptions) (any, error)
	FetchMany(ctx context.Context, opts FetchManyOptions) ([]any, error)
}

type FieldInArrayFilterOptions added in v0.0.5

type FieldInArrayFilterOptions struct {
	Field    string
	Elements []any
}

type FilterOptions added in v0.0.5

type FilterOptions struct {
	ConvertValues  bool
	QueryParams    map[string][]string
	MatchBehavior  MatchBehavior
	PrependStr     string
	AppendStr      string
	ExcludedFields []string
}

type FindManyHandlerOptions added in v0.1.270

type FindManyHandlerOptions struct {
	Atz
	Filter        bson.M
	SortDirection SortDirection
	Skip          int64
	Limit         int64
	ValidateQuery bool
}

type FindManyOptions added in v0.0.5

type FindManyOptions struct {
	FindManyHandlerOptions
	Collection string
	Receiver   any
	SortByKey  string
}

type FindOneHandlerOptions added in v0.1.360

type FindOneHandlerOptions struct {
	Bypass
}

type FindOneOptions added in v0.0.5

type FindOneOptions struct {
	Collection string
	Receiver   any
	IDKey      string
	ID         Identifier
}

type FirebaseAuthenticator added in v0.1.178

type FirebaseAuthenticator interface {
	AuthenticateFirebaseIDToken(ctx context.Context, r *http.Request, opts AuthOptions) error
}

type FirebaseMockUser added in v0.1.220

type FirebaseMockUser struct {
	Email    string
	Password string
}

type FirebaseOperator added in v0.1.10

type FirebaseOperator interface {
	FirebaseAuthenticator
	FirebaseUtil
	FirebaseTester
	InitFirebase(ctx context.Context, credentialsJSON []byte) (*firebase.App, error)
}

type FirebaseTester added in v0.1.219

type FirebaseTester interface {
	DeleteMockUser(ctx context.Context, email string) error
	CreateMockUser(ctx context.Context) (*FirebaseMockUser, error)
}

type FirebaseUtil added in v0.1.178

type FirebaseUtil interface {
	FirebaseIDToken(ctx context.Context, u FirebaseMockUser, apiKey string) (string, error)
	GenerateMockFirebaseUID(ctx context.Context, length int) (string, error)
	GetAPIKey(ctx context.Context) (string, error)
}

type GenerateUsernameOption added in v0.1.426

type GenerateUsernameOption func(*GenerateUsernameOptions)

func WithBaseDigit added in v0.1.426

func WithBaseDigit(x int) GenerateUsernameOption

func WithMaxPerName added in v0.1.426

func WithMaxPerName(x int) GenerateUsernameOption

func WithMinUsernameLen added in v0.1.426

func WithMinUsernameLen(x int) GenerateUsernameOption

func WithNames added in v0.1.426

func WithNames(x []string) GenerateUsernameOption

type GenerateUsernameOptions added in v0.1.426

type GenerateUsernameOptions struct {
	BaseDigit      int
	MaxPerName     int
	MinUsernameLen int
	Names          []string
}

func ApplyGenerateUsernameOptions added in v0.1.426

func ApplyGenerateUsernameOptions(opts *GenerateUsernameOptions, modifiers ...GenerateUsernameOption) GenerateUsernameOptions

type Generator added in v0.1.426

type Generator interface {
	GenerateUsername(ctx context.Context, opts GenerateUsernameOptions) (string, error)
	ReverseString(ctx context.Context, s string) (string, error)
}

type Geocoder

type Geocoder interface {
	TimezoneFromCoordinates(ctx context.Context, latitude, longitude float64) (string, error)
	CityFromCoordinates(ctx context.Context, latitude, longitude float64) (string, error)
	TimezoneDataFromCoordinates(ctx context.Context, latitude, longitude float64) (*maps.TimezoneResult, error)
	GeocodeCoordinates(ctx context.Context, latitude, longitude float64) ([]maps.GeocodingResult, error)
	SwapTimezone(ctx context.Context, t time.Time, tz string, toUTC, toMidnight bool) (time.Time, error)
	IsUTC(ctx context.Context, t time.Time) (bool, error)
}

type GmailMessager added in v0.1.381

type GmailMessager interface {
	Message(u *gmail.UsersMessagesSendCall, opts ...googleapi.CallOption) (*gmail.Message, error)
}

type GmailService added in v0.1.381

type GmailService any

type GmailUsersMessageService added in v0.1.381

type GmailUsersMessageService interface {
	Send(userID string, message *gmail.Message) *gmail.UsersMessagesSendCall
}

type GoogleMaps added in v0.0.5

type GoogleMaps interface {
	Timezone(ctx context.Context, r *maps.TimezoneRequest) (*maps.TimezoneResult, error)
	Geocode(ctx context.Context, r *maps.GeocodingRequest) ([]maps.GeocodingResult, error)
}

type GzipReader

type GzipReader interface {
	Read(ctx context.Context, r io.Reader) (io.Reader, error)
}

type GzipUtil

type GzipUtil interface {
	WriteGzip(ctx context.Context, w *gzip.Writer, r io.Reader) error
	CloseGzipWriter(ctx context.Context, w *gzip.Writer) error
	ReadGzip(ctx context.Context, r io.Reader) ([]byte, error)
	NewGzipReader(ctx context.Context, r io.Reader) (*gzip.Reader, error)
	CopyToBuffer(ctx context.Context, r *gzip.Reader, buf *bytes.Buffer) error
	CloseGzipReader(ctx context.Context, r *gzip.Reader) error
}

type GzipWriter

type GzipWriter interface {
	Write(ctx context.Context, r io.Reader) (io.Reader, int64, error)
}

type HTTPClient added in v0.0.5

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type HTTPDoer

type HTTPDoer interface {
	Do(ctx context.Context, r *http.Request) (*http.Response, error)
}

type HTTPFileOpener added in v0.1.377

type HTTPFileOpener interface {
	OpenFile(ctx context.Context, fsys http.FileSystem, name string) (http.File, error)
}

type HTTPHTML added in v0.1.5

type HTTPHTML interface {
	ServeHTML(ctx context.Context, w http.ResponseWriter, body io.Reader, status int) error
}

type HTTPOperator added in v0.1.377

type HTTPOperator interface {
	HTTPResponder
	HTTPUtil
	HTTPHTML
}

type HTTPRequester

type HTTPRequester interface {
	NewRequest(ctx context.Context, method, url string, opts RequestOptions) (*http.Request, error)
}

type HTTPResponder added in v0.1.5

type HTTPResponder interface {
	RespondJSON(ctx context.Context, w http.ResponseWriter, v any, status int, escapeHTML bool) error
}

type HTTPResponseWriter added in v0.1.14

type HTTPResponseWriter interface {
	Header() http.Header
	Write([]byte) (int, error)
	WriteHeader(statusCode int)
}

type HTTPServer added in v0.1.10

type HTTPServer interface {
	ListenAndServe() error
	ListenAndServeTLS(certFile string, keyFile string) error
	Shutdown(ctx context.Context) error
}

type HTTPUtil added in v0.1.5

type HTTPUtil interface {
	QueryString(ctx context.Context, pairs ...string) (string, error)
	ValidateQueryParams(ctx context.Context, q map[string][]string, rules ...QueryParamRule) error
	CopyHeaders(ctx context.Context, dst, src *http.Request, headers ...string) error
	GetHeaders(ctx context.Context, r *http.Request) (http.Header, error)
	DecodeBody(ctx context.Context, r *http.Request, v any) error
	SetQueryParams(ctx context.Context, r *http.Request, q map[string][]string, override bool) error
	ServeFile(ctx context.Context, opts ServeFileOptions) error
}

type HTTPWriter

type HTTPWriter interface {
	Write(ctx context.Context, w http.ResponseWriter, b []byte) (int, error)
}

type HandlerFunc added in v0.1.11

type HandlerFunc func(w http.ResponseWriter, r *http.Request) error

HandlerFunc defines a handler function.

func (HandlerFunc) Wrap added in v0.1.11

type ID added in v0.0.8

type ID struct {
	V *string `json:"id"`
}

ID is a custom type for database-agnostic unique IDs.

func NewID added in v0.0.8

func NewID() *ID

func NewIDFromQVals added in v0.1.61

func NewIDFromQVals(q config.QVals) *ID

func NewIDFromString added in v0.0.8

func NewIDFromString(v string) *ID

func (*ID) GetV added in v0.0.8

func (id *ID) GetV() string

func (*ID) IsEmpty added in v0.0.8

func (id *ID) IsEmpty() bool

func (*ID) MarshalJSON added in v0.1.40

func (id *ID) MarshalJSON() ([]byte, error)

func (*ID) SetV added in v0.0.8

func (id *ID) SetV(x string)

func (ID) String added in v0.0.8

func (id ID) String() string

func (*ID) UnmarshalJSON added in v0.1.40

func (id *ID) UnmarshalJSON(data []byte) error

type IDDecoder added in v0.1.317

type IDDecoder struct{}

func (IDDecoder) DecodeValue added in v0.1.317

func (IDDecoder) DecodeValue(_ bson.DecodeContext, vr bson.ValueReader, val reflect.Value) error

type IDEncoder added in v0.1.317

type IDEncoder struct{}

func (IDEncoder) EncodeValue added in v0.1.317

func (IDEncoder) EncodeValue(_ bson.EncodeContext, vw bson.ValueWriter, val reflect.Value) error

type Identifiable added in v0.0.5

type Identifiable interface {
	GetID() ID
	GetCreatedAt() time.Time
}

type Identifier added in v0.0.5

type Identifier interface {
	GetV() string
	SetV(string)
	IsEmpty() bool
	fmt.Stringer
	json.Marshaler
	json.Unmarshaler
}

type IndexEntry added in v0.0.5

type IndexEntry struct {
	Name               *string
	Field              string
	SortDirection      SortDirection
	ExpireAfterSeconds *int32
}

type Indexable added in v0.1.211

type Indexable interface {
	Idx(collection string) CreateIndexesOptions
	IdxSrch(collection string) CreateSearchIndexesOptions
}

type InitOption added in v0.1.385

type InitOption func(*InitOptions)

func WithInitUnmarshaler added in v0.1.392

func WithInitUnmarshaler(x Unmarshaler) InitOption

func WithRecipientEmail added in v0.1.385

func WithRecipientEmail(x string) InitOption

func WithRecipientUsername added in v0.1.385

func WithRecipientUsername(x string) InitOption

func WithSpecifics added in v0.1.385

func WithSpecifics(x string) InitOption

func WithSupportRedirectURL added in v0.1.390

func WithSupportRedirectURL(x string) InitOption

func WithTargetLanguage added in v0.1.385

func WithTargetLanguage(x string) InitOption

type InitOptions added in v0.1.385

type InitOptions struct {
	U                  Unmarshaler
	TargetLanguage     string
	RecipientEmail     string
	RecipientUsername  string
	SupportRedirectURL string
	Specifics          string
}

func ApplyInitOptions added in v0.1.385

func ApplyInitOptions(opts *InitOptions, modifiers ...InitOption) InitOptions

type InsertOneHandlerOptions added in v0.1.270

type InsertOneHandlerOptions struct {
	Atz
	Bypass
}

type InsertOneOptions added in v0.0.5

type InsertOneOptions struct {
	Collection string
	Document   Identifiable
}

type JSONOption

type JSONOption func(*JSONOptions)

func WithJSONEscapeHTML

func WithJSONEscapeHTML(escape bool) JSONOption

func WithJSONIndent

func WithJSONIndent(indent string) JSONOption

func WithJSONUseNumber

func WithJSONUseNumber(use bool) JSONOption

type JSONOptions

type JSONOptions struct {
	Indent     string // Enables indentation if non-empty.
	EscapeHTML bool   // Determines if HTML characters should be escaped.
	UseNumber  bool   // If true, decodes numbers as `json.Number` instead of `float64`.
}

JSONOptions defines settings for encoding/decoding.

func ApplyJSONOptions

func ApplyJSONOptions(opts *JSONOptions, modifiers ...JSONOption) JSONOptions

type Level

type Level = slog.Level
const (
	Debug Level = slog.LevelDebug
	Info  Level = slog.LevelInfo
	Warn  Level = slog.LevelWarn
	Error Level = slog.LevelError
	Sep         = "__________"
)

type LibraryOperator added in v0.1.45

type LibraryOperator interface {
	Svc(context.Context) (string, error)
}

type LimiterInfo added in v0.1.11

type LimiterInfo interface {
	GetMaxScore(ctx context.Context) (uint, error)
	GetHeaderKey(ctx context.Context) (string, error)
	GetRateLimitingMode(ctx context.Context) (string, error)
}

type LimiterOperator added in v0.1.10

type LimiterOperator interface {
	Engage(next HandlerFunc) HandlerFunc
	LimiterInfo
}

type LogOperator added in v0.1.10

type LogOperator interface {
	Log(ctx context.Context, l Level, v any, prefix string, msg ...string)
	Wrap(ctx context.Context, fn func() (any, error)) error
}

type MajorUnit added in v0.1.10

type MajorUnit = float64

type Marshaler

type Marshaler interface {
	Marshal(ctx context.Context, v any, opts JSONOptions) ([]byte, error)
}

type MatchBehavior added in v0.0.5

type MatchBehavior = string

MatchBehavior defines different matching behaviors in MongoDB queries, such as in, all, and eq.

type MessageRole added in v0.1.245

type MessageRole = string

MessageRole represents the role of a message.

const (
	// MessageRoleSystem is the role for the system message.
	MessageRoleSystem MessageRole = "system"
	// MessageRoleUser is the role for the user message.
	MessageRoleUser MessageRole = "user"
	// MessageRoleAssistant is the role for the assistant message.
	MessageRoleAssistant MessageRole = "assistant"
	// GrokChatCompletionURL is the URL for the Grok LLM API.
	GrokChatCompletionURL = "https://api.x.ai/v1/chat/completions"
	// Grok2LatestModel is the latest model for the Grok LLM.
	Grok2LatestModel = "grok-2-latest"
)

type MiddlewareFunc added in v0.1.10

type MiddlewareFunc func(HandlerFunc) HandlerFunc

MiddlewareFunc defines a composable middleware around a HandlerFunc.

type MiddlewareOperator added in v0.1.10

type MiddlewareOperator interface {
	Chain(fns ...MiddlewareFunc) MiddlewareFunc
	Gzip(next HandlerFunc) HandlerFunc
	EnforceHTTPS(next HandlerFunc) HandlerFunc
	CheckHeaders(next HandlerFunc) HandlerFunc
	CleanURLPath(next HandlerFunc) HandlerFunc
	IdempotentPOST(next HandlerFunc) HandlerFunc
	RequireReader(next HandlerFunc) HandlerFunc
	RequireWriter(next HandlerFunc) HandlerFunc
	RequireOwner(next HandlerFunc) HandlerFunc
	AuthenticateFirebaseIDToken(next HandlerFunc) HandlerFunc
	AuthenticateFirebaseModIDToken(next HandlerFunc) HandlerFunc
	AuthenticateOIDCToken(next HandlerFunc) HandlerFunc
	AuthenticateWithSecret(next HandlerFunc) HandlerFunc
	AuthenticateAny(next HandlerFunc) HandlerFunc
}

type MongoChangeStream added in v0.0.5

type MongoChangeStream interface {
	Close(ctx context.Context) error
	Next(ctx context.Context) bool
	Err() error
}

type MongoClient added in v0.0.5

type MongoClient interface {
	Database(name string, opts ...options.Lister[options.DatabaseOptions]) *mongo.Database
	StartSession(opts ...options.Lister[options.SessionOptions]) (*mongo.Session, error)
	Disconnect(ctx context.Context) error
}

type MongoCollection added in v0.0.5

type MongoCollection interface {
	InsertOne(ctx context.Context, document any, opts ...options.Lister[options.InsertOneOptions]) (*mongo.InsertOneResult, error)
	FindOne(ctx context.Context, filter any, opts ...options.Lister[options.FindOneOptions]) *mongo.SingleResult
	Find(ctx context.Context, filter any, opts ...options.Lister[options.FindOptions]) (*mongo.Cursor, error)
	ReplaceOne(ctx context.Context, filter any, document any, opts ...options.Lister[options.ReplaceOptions]) (*mongo.UpdateResult, error)
	DeleteOne(ctx context.Context, filter any, opts ...options.Lister[options.DeleteOneOptions]) (*mongo.DeleteResult, error)
	DeleteMany(ctx context.Context, filter any, opts ...options.Lister[options.DeleteManyOptions]) (*mongo.DeleteResult, error)
	Aggregate(ctx context.Context, pipeline any, opts ...options.Lister[options.AggregateOptions]) (*mongo.Cursor, error)
	Watch(ctx context.Context, pipeline any, opts ...options.Lister[options.ChangeStreamOptions]) (*mongo.ChangeStream, error)
}

type MongoCursor added in v0.0.5

type MongoCursor interface {
	Next(ctx context.Context) bool
	Decode(receiver any) error
	Err() error
}

type MongoDatabase added in v0.0.5

type MongoDatabase interface {
	Watch(ctx context.Context, pipeline any, opts ...options.Lister[options.ChangeStreamOptions]) (*mongo.ChangeStream, error)
}

type MongoFilter added in v0.0.5

type MongoFilter interface {
	Filter(ctx context.Context, opts FilterOptions) (bson.M, error)
	FilterByFieldInArray(ctx context.Context, opts FieldInArrayFilterOptions) (bson.M, error)
	FilterByElemMatch(ctx context.Context, opts ElemMatchFilterOptions) (bson.M, error)
	FilterByElemsInArray(ctx context.Context, opts ElemsInArrayFilterOptions) (bson.M, error)
	FilterByAllElemsInArray(ctx context.Context, opts ElemsInArrayFilterOptions) (bson.M, error)
	FilterByFutureDate(ctx context.Context, opts DateFilterOptions) (bson.D, error)
	FilterByPastDate(ctx context.Context, opts DateFilterOptions) (bson.D, error)
	FilterByExactDate(ctx context.Context, opts DateFilterOptions) (bson.D, error)
	CombineM(ctx context.Context, op BSONOperator, m ...bson.M) (bson.M, error)
}

type MongoLookupTarget added in v0.0.5

type MongoLookupTarget = string

MongoLookupTarget specifies the target field for the lookup stage in a MongoDB aggregation pipeline.

type MongoOperator added in v0.0.5

type MongoOperator interface {
	MongoUtil
	MongoFilter
	MongoSpecialized
	CloserWithCtx
}

type MongoOutCSChan added in v0.0.5

type MongoOutCSChan = chan *ChangeEvent

MongoOutCSChan is a channel type used for sending decoded MongoDB change events.

type MongoPipeliner added in v0.0.5

type MongoPipeliner interface {
	Pipeline() mongo.Pipeline
}

func NewPipeline added in v0.1.334

func NewPipeline(p mongo.Pipeline) MongoPipeliner

type MongoSpecialized added in v0.0.5

type MongoSpecialized interface {
	Search(ctx context.Context, opts SearchOptions) (*SearchResult, error)
	WatchCollection(ctx context.Context, opts WatchCollectionOptions) error
	WatchDB(ctx context.Context, opts WatchDBOptions) error
	ProcessChangeStream(ctx context.Context, opts ProcessChangeStreamOptions) error
	RunPipeline(ctx context.Context, opts RunPipelineOptions) ([]any, error)
}

type MongoUtil added in v0.0.5

type MongoUtil interface {
	WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error
	Collection(ctx context.Context, db, collection string) (MongoCollection, error)
	Database(ctx context.Context, db string) (MongoDatabase, error)
}

type MongoVerb added in v0.0.5

type MongoVerb = string

MongoVerb defines a MongoDB operation keyword, such as match.

type NormalizeOption added in v0.1.336

type NormalizeOption func(*NormalizeOptions)

func WithRemoveDiacritics added in v0.1.336

func WithRemoveDiacritics() NormalizeOption

func WithRemoveDigits added in v0.1.336

func WithRemoveDigits() NormalizeOption

func WithRemoveNonASCII added in v0.1.336

func WithRemoveNonASCII() NormalizeOption

func WithRemovePunctuation added in v0.1.336

func WithRemovePunctuation() NormalizeOption

func WithRemoveSymbols added in v0.1.336

func WithRemoveSymbols() NormalizeOption

func WithToLower added in v0.1.336

func WithToLower() NormalizeOption

func WithTrimSpace added in v0.1.336

func WithTrimSpace() NormalizeOption

type NormalizeOptions added in v0.1.336

type NormalizeOptions struct {
	ToLower        bool
	RemoveDiacs    bool
	TrimSpace      bool
	RemovePunct    bool
	RemoveSpec     bool
	RemoveDigits   bool
	RemoveNonASCII bool
}

func ApplyNormalizeOptions added in v0.1.336

func ApplyNormalizeOptions(opts *NormalizeOptions, modifiers ...NormalizeOption) NormalizeOptions

type Normalizer added in v0.1.336

type Normalizer interface {
	Normalize(ctx context.Context, s string, opts NormalizeOptions) (string, error)
}

type OIDCAuthenticator added in v0.1.178

type OIDCAuthenticator interface {
	AuthenticateOIDCToken(ctx context.Context, r *http.Request, opts AuthOptions) error
}

type OIDCCreator added in v0.1.178

type OIDCCreator interface {
	CreateOIDCToken(ctx context.Context) (*oauth2.Token, error)
}

type OIDCOperator added in v0.1.178

type OIDCOperator interface {
	OIDCAuthenticator
	OIDCCreator
}

type OperationResult added in v0.1.56

type OperationResult struct {
	// Message is the optional operation message.
	Message string `json:"message,omitempty"`
	// ID is the optional ressource identifier.
	ID *ID `json:"id,omitempty"`
	// Value is an optional result object.
	Value any `json:"value,omitempty"`
}

Operation is a general-purpose response struct.

func NewOperationResult added in v0.1.57

func NewOperationResult(opts ...OperationResultOption) *OperationResult

type OperationResultOption added in v0.1.56

type OperationResultOption func(*OperationResult)

func WithID added in v0.1.56

func WithID(x *ID) OperationResultOption

func WithMessage added in v0.1.56

func WithMessage(x string) OperationResultOption

func WithValue added in v0.1.56

func WithValue(x any) OperationResultOption

type PaginationOptions added in v0.0.5

type PaginationOptions struct {
	PageNumber int32
	PageSize   int32
}

func (*PaginationOptions) Verify added in v0.0.5

func (p *PaginationOptions) Verify() error

type Parser added in v0.1.336

type Parser interface {
	ParseDynamicType(ctx context.Context, s string) (any, error)
	ParseQueryString(ctx context.Context, s string) (map[string][]string, error)
}

type PeriodOperator added in v0.1.10

type PeriodOperator interface {
	FirstPeriodStartDate(ctx context.Context, year int) (time.Time, error)
	LastDayOfLastPeriod(ctx context.Context, year int) (time.Time, error)
	FirstDayOfMonth(ctx context.Context, date time.Time) (time.Time, error)
	PeriodNumber(ctx context.Context, date time.Time) (int, error)
	TimeOfWeekday(ctx context.Context, date time.Time, weekday time.Weekday) (time.Time, error)
}

type PoolOperator added in v0.1.10

type PoolOperator interface {
	Acquire(ctx context.Context) error
	Release(ctx context.Context) error
	ActiveWorkers(ctx context.Context) (int, error)
	WaitAll(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

type ProcessChangeStreamOptions added in v0.0.5

type ProcessChangeStreamOptions struct {
	ChangeStream MongoChangeStream
	LookupKey    string
	Receiver     any
	Output       MongoOutCSChan
}

type PromptMessage added in v0.1.245

type PromptMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

PromptMessage represents a message in the conversation. For contextual messages, see:

type PromptRequest added in v0.1.245

type PromptRequest struct {
	Model       string                `json:"model"`
	M           []PromptMessage       `json:"messages"`
	Stream      bool                  `json:"stream,omitempty"`
	Temperature float64               `json:"temperature,omitempty"`
	R           *PromptResponseFormat `json:"response_format,omitempty"`
}

PromptRequest represents the payload for the LLM API request.

type PromptResponse added in v0.1.245

type PromptResponse struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int    `json:"created"`
	Model   string `json:"model"`
	Choices []struct {
		Index   int `json:"index"`
		Message struct {
			Role    string `json:"role"`
			Content string `json:"content"`
			Refusal string `json:"refusal,omitempty"`
		} `json:"message"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
	Usage struct {
		PromptTokens        int `json:"prompt_tokens"`
		CompletionTokens    int `json:"completion_tokens"`
		TotalTokens         int `json:"total_tokens"`
		PromptTokensDetails struct {
			TextTokens   int `json:"text_tokens"`
			AudioTokens  int `json:"audio_tokens"`
			ImageTokens  int `json:"image_tokens"`
			CachedTokens int `json:"cached_tokens"`
		} `json:"prompt_tokens_details"`
	} `json:"usage"`
	SystemFingerprint string `json:"system_fingerprint"`
}

PromptResponse represents the response from the Grok LLM API.

type PromptResponseFormat added in v0.1.245

type PromptResponseFormat struct {
	Type       string        `json:"type"`
	JSONSchema *schemaFormat `json:"json_schema,omitempty"`
}

PromptResponseFormat represents the response format customization.

type Prompter added in v0.1.245

type Prompter interface {
	Prompt(ctx context.Context, opts PrompterOpts) (string, error)
}

type PrompterOpts added in v0.1.245

type PrompterOpts struct {
	SystemPrompt   string                // The system prompt for the LLM.
	UserPrompt     string                // The user prompt for the LLM.
	Context        []PromptMessage       // The context for the LLM.
	Temperature    float64               // The temperature for the LLM.
	R              *PromptResponseFormat // The response format for the LLM.
	AdditionalOpts map[string]any        // Additional options for the LLM to be implemented by prompters, optionally.
}

PrompterOpts represents the options for the Prompter.

type PubSubClient added in v0.1.162

type PubSubClient interface {
	Topic(id string) *pubsub.Topic
	CreateSubscription(ctx context.Context, id string, cfg pubsub.SubscriptionConfig) (*pubsub.Subscription, error)
	CreateTopic(ctx context.Context, topicID string) (*pubsub.Topic, error)
}

type PubSubFamily added in v0.1.162

type PubSubFamily struct {
	Topic             *PubSubTopic
	PushSubscriptions []*PubSubPushSubscription
	PullSubscriptions []*PubSubPullSubscription
}

type PubSubKey added in v0.1.366

type PubSubKey = string

func ToPubSubKey added in v0.1.366

func ToPubSubKey(s string) PubSubKey

ToPubSubKey converts a string to lowercase.

type PubSubMessage added in v0.0.5

type PubSubMessage interface {
	GetData() []byte
	GetAttributes() map[string]string
	GetMessageID() string
	GetPublishTime() time.Time
}

type PubSubOperator added in v0.1.10

type PubSubOperator interface {
	MockPayload(ctx context.Context, msg PubSubMessage, sub string) (*PubSubPayload, error)
	DecodePayload(ctx context.Context, r *http.Request) (PubSubMessage, error)
	Publish(ctx context.Context, topicID string, msg *pubsub.Message) error
	NewMessage(ctx context.Context, data string, attrs map[string]string) (*pubsub.Message, error)
	NewAttributes(ctx context.Context, attrs ...string) (map[string]string, error)
}

type PubSubPayload added in v0.1.367

type PubSubPayload struct {
	Message      pubsub.Message `json:"message,omitempty"`
	Subscription string         `json:"subscription,omitempty"`
}

type PubSubPullSubscription added in v0.1.162

type PubSubPullSubscription struct {
	ID string
}

type PubSubPushSubscription added in v0.1.162

type PubSubPushSubscription struct {
	ID           string
	PushEndpoint string
}

type PubSubTopic added in v0.1.162

type PubSubTopic struct {
	ID string
}

type QueryHandlerOptions added in v0.1.274

type QueryHandlerOptions struct {
	Atz
}

type QueryParamRule added in v0.1.5

type QueryParamRule struct {
	Key                   string   // Name of the query parameter.
	DefaultValue          string   // Default value if not provided in the request.
	AcceptedValues        []string // Accepted values; nil allows any value.
	MultipleValuesAllowed bool     // Whether multiple values are permitted.
	Optional              bool     // Whether the parameter is optional.
}

QueryParamRule defines validation rules for a query parameter. It specifies constraints such as key, default value, allowed values, and multiplicity.

type QueryParamRules added in v0.1.72

type QueryParamRules []QueryParamRule

func (*QueryParamRules) AppendMany added in v0.1.73

func (q *QueryParamRules) AppendMany(r QueryParamRules)

AppendMany appends multiple QueryParamRules to the QueryParamRules.

func (*QueryParamRules) AppendOne added in v0.1.73

func (q *QueryParamRules) AppendOne(r QueryParamRule)

Append appends a QueryParamRule to the QueryParamRules.

type Queryable added in v0.1.68

type Queryable interface {
	Rules() QueryParamRules
}

type RangeOption added in v0.1.338

type RangeOption func(*RangeOptions)

func WithMax added in v0.1.338

func WithMax(x float64) RangeOption

func WithMin added in v0.1.338

func WithMin(x float64) RangeOption

type RangeOptions added in v0.1.338

type RangeOptions struct {
	Min float64
	Max float64
}

func ApplyRangeOptions added in v0.1.338

func ApplyRangeOptions(opts *RangeOptions, modifiers ...RangeOption) RangeOptions

type RawCacheKey added in v0.1.3

type RawCacheKey string

RawCacheKey wraps a string key to implement fmt.Stringer.

func (RawCacheKey) String added in v0.1.3

func (r RawCacheKey) String() string

String implements the Stringer interface for RawCacheKey.

type Reader

type Reader interface {
	Read(ctx context.Context, r io.Reader) ([]byte, error)
}

type RedisClient added in v0.0.5

type RedisClient interface {
	Closer
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
	FlushAll(ctx context.Context) *redis.StatusCmd
	Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd
	TxPipeline() redis.Pipeliner
	Exists(ctx context.Context, keys ...string) *redis.IntCmd
	Pipeline() redis.Pipeliner
}

type RedisOperator added in v0.1.10

type RedisOperator interface {
	Cacher
}

type ReflectOperator added in v0.1.10

type ReflectOperator interface {
	FillNilPointers(ctx context.Context, to, from any) error
}

type RegisteredRoute added in v0.1.10

type RegisteredRoute struct {
	MethodMap map[string]Entry
}

RegisteredRoute holds a map of HTTP methods to route entries.

type Registry added in v0.1.10

type Registry map[*regexp.Regexp]*RegisteredRoute

Registry maps compiled regex patterns to registered routes.

func (*Registry) LenHandlers added in v0.1.10

func (r *Registry) LenHandlers() int

LenHandlers returns the total number of handlers across all routes.

func (*Registry) LenRoutes added in v0.1.10

func (r *Registry) LenRoutes() int

LenRoutes returns the number of registered routes.

type RegistryMutex added in v0.1.10

type RegistryMutex struct {
	sync.RWMutex
}

RegistryMutex provides thread-safe access to the route registry.

type RenderOption added in v0.1.385

type RenderOption func(*RenderOptions)

func WithData added in v0.1.385

func WithData(x any) RenderOption

func WithEmailable added in v0.1.385

func WithEmailable(x Emailable) RenderOption

func WithFuncs added in v0.1.385

func WithFuncs(x template.FuncMap) RenderOption

func WithRenderWriter added in v0.1.385

func WithRenderWriter(x io.Writer) RenderOption

func WithTemplate added in v0.1.385

func WithTemplate(x string) RenderOption

type RenderOptions added in v0.1.385

type RenderOptions struct {
	Template string
	Data     any
	W        io.Writer
	Funcs    template.FuncMap
}

func ApplyRenderOptions added in v0.1.385

func ApplyRenderOptions(opts *RenderOptions, modifiers ...RenderOption) RenderOptions

type ReplaceOneHandlerOptions added in v0.1.270

type ReplaceOneHandlerOptions struct {
	Atz
	Bypass
}

type ReplaceOneOptions added in v0.0.5

type ReplaceOneOptions struct {
	Collection string
	Document   Identifiable
	IDKey      string
	ID         Identifier
}

type RequestOption

type RequestOption func(*RequestOptions)

func WithRequestBody

func WithRequestBody(x io.Reader) RequestOption

func WithRequestHeader

func WithRequestHeader(x http.Header) RequestOption

type RequestOptions

type RequestOptions struct {
	Header http.Header
	Body   io.Reader
}

func ApplyRequestOptions

func ApplyRequestOptions(opts *RequestOptions, modifiers ...RequestOption) RequestOptions

type RequestWeight added in v0.1.10

type RequestWeight = uint

RequestWeight defines the relative cost of a request for rate limiting.

const (
	// Unlimited disables rate limiting for the request.
	Unlimited RequestWeight = 0
)

type RequireOption added in v0.1.338

type RequireOption func(*RequireOptions)

func WithNonNilPointer added in v0.1.338

func WithNonNilPointer() RequireOption

func WithNonZeroValue added in v0.1.338

func WithNonZeroValue() RequireOption

type RequireOptions added in v0.1.338

type RequireOptions struct {
	NonNilPointer bool
	NonZeroValue  bool
}

func ApplyRequireOptions added in v0.1.338

func ApplyRequireOptions(opts *RequireOptions, modifiers ...RequireOption) RequireOptions

type Role added in v0.1.50

type Role int
const (
	NA Role = iota
	Rdr
	Wrtr
	Ownr
)

func (Role) Validate added in v0.1.50

func (r Role) Validate() error

type Route added in v0.1.10

type Route struct {
	Svc         string
	Pairs       []string
	HandlerFunc HandlerFunc
	Weight      uint
	Methods     []string
}

Route holds route metadata to be compiled and registered.

func (Route) CompileRegex added in v0.1.10

func (r Route) CompileRegex(pathKey string) (*regexp.Regexp, error)

compileRegex builds a compiled regex for matching the route.

func (*Route) Validate added in v0.1.10

func (r *Route) Validate() error

type RouterKeyExtractor added in v0.1.198

type RouterKeyExtractor interface {
	SvcKey(ctx context.Context) (string, error)
	RKey(ctx context.Context) (string, error)
}

type RouterOperator added in v0.1.10

type RouterOperator interface {
	RouterParser
	RouterKeyExtractor
	Run(ctx context.Context) error
	Mount(ctx context.Context, r []*Route) error
	Stop(ctx context.Context) error
	Vars(ctx context.Context) (*config.Vars, error)
	AttachServer(ctx context.Context, s ServerOperator) error
}

type RouterParser added in v0.1.27

type RouterParser interface {
	ParsePath(ctx context.Context, r *http.Request, re *regexp.Regexp) (map[string]string, error)
	ParseQuery(ctx context.Context, r *http.Request) (map[string][]string, error)
}

type RunPipelineOptions added in v0.1.79

type RunPipelineOptions struct {
	Collection string
	Receiver   any
	Pipeline   MongoPipeliner
}

type Scopable added in v0.1.60

type Scopable interface {
	Scope() Scope
}

type Scope added in v0.1.66

type Scope struct {
	K  string
	ID ID
}

type SearchIndexEntry added in v0.0.5

type SearchIndexEntry struct {
	Fields      AtlasIndexes
	VectorField *VectorSearchField
}

type SearchManyHandlerOptions added in v0.1.270

type SearchManyHandlerOptions struct {
	Atz
	Filter        bson.M
	SortByKey     string
	SortDirection SortDirection
}

type SearchOptions added in v0.0.5

type SearchOptions struct {
	SearchManyHandlerOptions
	Collection string
	Receiver   any
	T          *TextOptions
	P          *PaginationOptions
}

type SearchResult added in v0.1.56

type SearchResult struct {
	Results    []any `json:"results,omitempty"`
	TotalCount int32 `json:"total_count,omitempty"`
	LastPage   int32 `json:"last_page,omitempty"`
}

SearchResult represents the response from a search operation.

func NewSearchResult added in v0.1.57

func NewSearchResult(opts ...SearchResultOption) *SearchResult

type SearchResultOption added in v0.1.56

type SearchResultOption func(*SearchResult)

func WithSearchLastPage added in v0.1.56

func WithSearchLastPage(x int32) SearchResultOption

func WithSearchResults added in v0.1.56

func WithSearchResults(x []any) SearchResultOption

func WithSearchTotalCount added in v0.1.56

func WithSearchTotalCount(x int32) SearchResultOption

type Searchable added in v0.1.75

type Searchable interface {
	SearchIn() []string
}

type SecretInfo added in v0.1.13

type SecretInfo struct {
	SecretID  string
	VersionID string
}

SecretInfo holds the identifiers needed to access a secret.

func (SecretInfo) BuildSecretName added in v0.1.13

func (s SecretInfo) BuildSecretName(projectID string) string

BuildSecretName constructs the full secret name path for Secret Manager.

type SecretManagerClient added in v0.1.13

type SecretManagerClient interface {
	AccessSecretVersion(ctx context.Context, req *secretmanagerpb.AccessSecretVersionRequest, opts ...gax.CallOption) (*secretmanagerpb.AccessSecretVersionResponse, error)
	Close() error
}

type SecretOperator added in v0.1.13

type SecretOperator interface {
	GetSecret(ctx context.Context, s SecretInfo) ([]byte, error)
	CloserWithCtx
}

type SemaphoreInfo added in v0.1.11

type SemaphoreInfo interface {
	GetConcurrency(ctx context.Context) (int, error)
}

type SemaphoreOperator added in v0.1.10

type SemaphoreOperator interface {
	Acquire(ctx context.Context) error
	Release(ctx context.Context) error
	WaitAll(ctx context.Context) error
	SemaphoreInfo
}

type SendEmailOption added in v0.1.381

type SendEmailOption func(*SendEmailOptions)

func WithBcc added in v0.1.381

func WithBcc(x ...string) SendEmailOption

func WithCc added in v0.1.381

func WithCc(x ...string) SendEmailOption

func WithContent added in v0.1.381

func WithContent(x io.Reader) SendEmailOption

func WithSender added in v0.1.381

func WithSender(x *EmailSenderInfo) SendEmailOption

func WithSubject added in v0.1.381

func WithSubject(x string) SendEmailOption

func WithTo added in v0.1.381

func WithTo(x ...string) SendEmailOption

type SendEmailOptions added in v0.1.381

type SendEmailOptions struct {
	Sender  *EmailSenderInfo
	Subject string
	Content io.Reader
	To      []string
	Cc      []string
	Bcc     []string
}

func ApplySendEmailOptions added in v0.1.381

func ApplySendEmailOptions(opts *SendEmailOptions, modifiers ...SendEmailOption) SendEmailOptions

type ServeFileOption added in v0.1.377

type ServeFileOption func(*ServeFileOptions)

func WithFS added in v0.1.377

func WithFS(x fs.FS) ServeFileOption

func WithReplacePath added in v0.1.377

func WithReplacePath(x string) ServeFileOption

func WithRequest added in v0.1.377

func WithRequest(x *http.Request) ServeFileOption

func WithStripPrefix added in v0.1.377

func WithStripPrefix(x string) ServeFileOption

func WithWriter added in v0.1.377

func WithWriter(x http.ResponseWriter) ServeFileOption

type ServeFileOptions added in v0.1.377

type ServeFileOptions struct {
	W         http.ResponseWriter
	R         *http.Request
	ToStrip   string
	ToReplace string
	FS        fs.FS
}

func ApplyServeFileOptions added in v0.1.377

func ApplyServeFileOptions(opts *ServeFileOptions, modifiers ...ServeFileOption) ServeFileOptions

type ServerInfo added in v0.1.11

type ServerInfo interface {
	GetUseHTTP2(ctx context.Context) (bool, error)
	GetUseH2C(ctx context.Context) (bool, error)
	GetBoundOn(ctx context.Context) (string, error)
	GetIdleTimeout(ctx context.Context) (time.Duration, error)
	GetReadTimeout(ctx context.Context) (time.Duration, error)
	GetWriteTimeout(ctx context.Context) (time.Duration, error)
}

type ServerOperator added in v0.1.11

type ServerOperator interface {
	http.Handler
	ServerRunner
	ServerInfo
}

type ServerRunner added in v0.1.11

type ServerRunner interface {
	Run(ctx context.Context) error
	Shutdown(ctx context.Context) error
	WithNotFoundHandler(ctx context.Context, x HandlerFunc) error
}

type SortDirection added in v0.0.5

type SortDirection int

SortDirection represents the sorting order for MongoDB queries.

type Sortable added in v0.1.62

type Sortable interface {
	SortBy() string
}

type StringOperator added in v0.1.336

type StringOperator interface {
	Generator
	Normalizer
	Conformer
	Parser
}

type TemplateOperator added in v0.1.385

type TemplateOperator interface {
	TemplateRenderer
}

type TemplateRenderer added in v0.1.385

type TemplateRenderer interface {
	Render(ctx context.Context, opts RenderOptions) error
}

type TextOptions added in v0.0.5

type TextOptions struct {
	Query  string
	Fields []string
}

type Tool

type Tool[C any] struct {
	Client C
	Logger LogOperator
}

func NewTool

func NewTool[C any](client C, opts ToolOptions[C]) *Tool[C]

type ToolOption

type ToolOption[C any] func(*ToolOptions[C])

func WithLogger

func WithLogger[C any](x LogOperator) ToolOption[C]

type ToolOptions

type ToolOptions[C any] struct {
	Logger LogOperator
}

func ApplyToolOptions added in v0.1.12

func ApplyToolOptions[C any](opts *ToolOptions[C], modifiers ...ToolOption[C]) ToolOptions[C]

type TranslateClient added in v0.1.384

type TranslateClient interface {
	Translate(ctx context.Context, inputs []string, target language.Tag, opts *translate.Options) ([]translate.Translation, error)
	SupportedLanguages(ctx context.Context, target language.Tag) ([]translate.Language, error)
	Close() error
}

type TranslateCommonOption added in v0.1.393

type TranslateCommonOption func(*TranslateCommonOptions)

func WithBaseOnly added in v0.1.393

func WithBaseOnly(x bool) TranslateCommonOption

func WithSourceTag added in v0.1.393

func WithSourceTag(x language.Tag) TranslateCommonOption

func WithTargetTag added in v0.1.393

func WithTargetTag(x language.Tag) TranslateCommonOption

type TranslateCommonOptions added in v0.1.384

type TranslateCommonOptions struct {
	SourceTag language.Tag
	Target    language.Tag
	BaseOnly  bool
}

type TranslateHTMLOption added in v0.1.393

type TranslateHTMLOption func(*TranslateHTMLOptions)

func WithHTMLReader added in v0.1.393

func WithHTMLReader(x io.Reader) TranslateHTMLOption

func WithHTMLSelector added in v0.1.393

func WithHTMLSelector(x string) TranslateHTMLOption

type TranslateHTMLOptions added in v0.1.384

type TranslateHTMLOptions struct {
	TranslateCommonOptions
	R        io.Reader
	Selector string
}

func ApplyTranslateHTMLOptions added in v0.1.393

func ApplyTranslateHTMLOptions(base *TranslateHTMLOptions, htmlModifiers []TranslateHTMLOption, commonModifiers ...TranslateCommonOption) TranslateHTMLOptions

type TranslateTextOption added in v0.1.393

type TranslateTextOption func(*TranslateTextOptions)

func WithConvertLineBreaks added in v0.1.393

func WithConvertLineBreaks(x bool) TranslateTextOption

func WithText added in v0.1.393

func WithText(x string) TranslateTextOption

func WithTranslateOpts added in v0.1.393

func WithTranslateOpts(x *translate.Options) TranslateTextOption

type TranslateTextOptions added in v0.1.384

type TranslateTextOptions struct {
	TranslateCommonOptions
	Text              string
	ConvertLineBreaks bool
	Opts              *translate.Options
}

func ApplyTranslateTextOptions added in v0.1.393

func ApplyTranslateTextOptions(base *TranslateTextOptions, textModifiers []TranslateTextOption, commonModifiers ...TranslateCommonOption) TranslateTextOptions

type TranslationOperator added in v0.1.384

type TranslationOperator interface {
	TranslateText(ctx context.Context, opts TranslateTextOptions) (string, error)
	TranslateHTML(ctx context.Context, opts TranslateHTMLOptions) (io.Reader, error)
	ParseLanguage(ctx context.Context, BCP47Code string) (*language.Tag, error)
	SuggestBestMatch(ctx context.Context, userLanguage, fallback language.Tag) (*language.Tag, error)
	CloserWithCtx
}

type TwilioAPIService added in v0.1.364

type TwilioAPIService interface {
	CreateMessage(params *twilioApi.CreateMessageParams) (*twilioApi.ApiV2010Message, error)
}

type TwilioClient added in v0.1.364

type TwilioClient interface{}

type TwilioOperator added in v0.1.364

type TwilioOperator interface {
	TwilioSMS
}

type TwilioSMS added in v0.1.364

type TwilioSMS interface {
	SendPlainSMS(ctx context.Context, s sms.SMS) ([]byte, error)
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(ctx context.Context, data io.Reader, v any, opts JSONOptions) error
}

type ValidationOperator added in v0.1.338

type ValidationOperator interface {
	Validate(ctx context.Context, k string, v any) error
}

type VectorSearchField added in v0.0.5

type VectorSearchField struct {
	NumDimensions int
	Field         string
	Similarity    string
	Quantization  string
	Additionals   []string
}

type Visibility added in v0.1.409

type Visibility uint
const (
	Private Visibility = iota
	Contacts
	All
)

func (Visibility) Validate added in v0.1.411

func (v Visibility) Validate() error

type WatchCollectionOptions added in v0.0.5

type WatchCollectionOptions struct {
	Collection string
	Receiver   any
	Pipeline   MongoPipeliner
	Options    *options.ChangeStreamOptionsBuilder
	LookupKey  string
	Output     MongoOutCSChan
}

type WatchDBOptions added in v0.0.5

type WatchDBOptions struct {
	Receiver  any
	Pipeline  MongoPipeliner
	Options   *options.ChangeStreamOptionsBuilder
	LookupKey string
	Output    MongoOutCSChan
}

type Writer added in v0.1.381

type Writer interface {
	Write(ctx context.Context, w io.Writer, data []byte) error
}

Jump to

Keyboard shortcuts

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