gx

package module
v0.19.9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Unlicense Imports: 80 Imported by: 1

README

grapherX (gX)

Documentation

Index

Constants

View Source
const (
	CountKey  Definition = "count"
	OffsetKey Definition = "offset"
	SortKey   Ignore     = "sort"
	IdKey     string     = "_id"
	KeyKey    string     = "_key"
	FromKey   string     = "_from"
	ToKey     string     = "_to"
)
View Source
const (
	// RequestMaxBodySize limits the amount of data read from the request body to prevent memory exhaustion
	RequestMaxBodySize = 2 * 1024 * 1024 // 2 MB
)

Variables

View Source
var (
	OTPRequestedTopic   = Topic("auth.otp.requested")
	NonceRequestedTopic = Topic("auth.nonce.requested")
)
View Source
var (
	True  = Eq{To: true}
	False = Eq{To: false}
)
View Source
var AccessModule = fx.Module("access",
	Provide[Access](NewArangoAccess),
)

AccessModule ...

View Source
var AuthModule = fx.Module("authHandler",

	fx.Provide(NewAuthHandler),
	fx.Invoke(func(ctx context.Context, router *http.ServeMux, auth *AuthHandler) {
		router.Handle("/auth/", auth.Handler(ctx))
	}),
)

AuthModule ...

View Source
var BitcoinDashboardModule = fx.Module("bitcoin-dashboard",
	fx.Invoke(func(ctx context.Context, router *http.ServeMux, auth *AuthHandler, dashboard *DashboardHandler, payment *BitcoinPaymentGateway) {
		router.Handle("/bitcoin-dashboard/", payment.DashboardHandler(ctx, auth, dashboard))
	}),
)

BitcoinDashboardModule ...

View Source
var BitcoinModule = fx.Module("bitcoin",

	fx.Provide(NewBitcoinPaymentGateway),
	fx.Invoke(func(ctx context.Context, router *http.ServeMux, payment *BitcoinPaymentGateway) {
		router.Handle("/bitcoin/", payment.Handler(ctx))
	}),
)

BitcoinModule ...

View Source
var ConnectionModule = fx.Module("connection",

	Provide[Connection](NewConnection),
)

ConnectionModule ...

View Source
var DashboardModule = fx.Module("dashboard",

	fx.Provide(NewDashboard),
	fx.Invoke(func(ctx context.Context, router *http.ServeMux, dashboard *DashboardHandler, auth *AuthHandler) {
		router.Handle("/dashboard/", dashboard.Handler(ctx, auth))
	}),
)

DashboardModule ...

View Source
var DbFileStorageModule = fx.Module("dbFileStorage",
	Provide[FileStorage](NewDbFileStorage),
	StorageHandlerModule,
)

DbFileStorageModule ...

View Source
var FileSystemStorageModule = fx.Module("filesystemStorage",

	Provide[FileStorage](NewFilesystemStorage),
	StorageHandlerModule,
)

FileSystemStorageModule ...

View Source
var GraphModule = fx.Module("graph",
	Provide[Graph](NewGraph),
)

GraphModule ...

View Source
var GraphqlModule = fx.Module("graphql",
	fx.Provide(handler.New),
	fx.Invoke(func(router *http.ServeMux, handler *handler.Handler) {
		router.Handle("/graphql/", handler)
	}),
)
View Source
var ObserverModule = fx.Module("observer",
	Provide[Observer[Topic]](NewObserver[Topic]),
)
View Source
var ServerModule = fx.Module("server",
	fx.Provide(http.NewServeMux),

	fx.Invoke(func(ctx context.Context, lc fx.Lifecycle, router *http.ServeMux, config Config) {
		srv := &http.Server{
			Addr:        config.Router.Address,
			Handler:     Chain(config.Middlewares...)(router),
			BaseContext: func(net.Listener) context.Context { return ctx },
		}

		if config.Router.Cors != nil {
			c := cors.New(cors.Options{
				AllowedMethods:   config.Router.Cors.AllowedMethods,
				AllowedHeaders:   config.Router.Cors.AllowedHeaders,
				AllowCredentials: config.Router.Cors.AllowCredentials,
				AllowOriginFunc: func(string) bool {
					return config.Router.Cors.AllowOriginFunc
				},
			})
			srv.Handler = c.Handler(srv.Handler)
		}

		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				ln, err := net.Listen("tcp", srv.Addr)
				if err != nil {
					return fmt.Errorf("error listening: %v", err)
				}
				go srv.Serve(ln)
				return nil
			},
			OnStop: func(ctx context.Context) error {
				return srv.Shutdown(ctx)
			},
		})
	}),
)

ServerModule ...

View Source
var StorageHandlerModule = fx.Module("storageHandler",
	fx.Invoke(func(router *http.ServeMux, storage FileStorage) {
		router.Handle("/files/{hash}", HandleDownloadFile(storage))
		router.Handle("/files", HandleUploadFile(storage))
	}),
)

StorageHandlerModule ...

Functions

func Account added in v0.18.0

func Account[T proto.Message](ctx context.Context, subject AccountFn[T]) (val T, err error)

Account returns a value and an error from a SubjectFn

func AdminFromContext added in v0.19.0

func AdminFromContext(ctx context.Context) (value *accountv1.Admin, found bool)

func Authorize added in v0.19.0

func Authorize(ctx context.Context, resource string, scope accountv1.Admin_Scope) error

Authorize checks if the current admin has the given scope for the given resource

func Broadcast

func Broadcast[T comparable](observer Observer[T], payload protoreflect.ProtoMessage, topics ...T)

Broadcast emits an event to the observer for the given topics

func COUNT

func COUNT[T proto.Message](filters Filters) (q string, bindVars map[string]interface{})

COUNT returns the number of documents in a collection

Example: "RETURN COUNT(FOR doc IN col FILTER doc.name == @name RETURN doc)" {"name": "John"}

func Collection

func Collection[T any]() string

Collection returns the name of the collection for the given element

func ConfigFromEnv

func ConfigFromEnv[T proto.Message](defaultConf T) T

func ConnectionClosed

func ConnectionClosed(conn *websocket.Conn) <-chan struct{}

ConnectionClosed returns a channel that is closed when the connection is closed

func DOCUMENT

func DOCUMENT(id string) (q string, bindVars map[string]interface{})

DOCUMENT returns a document by its id

Example: "RETURN DOCUMENT(@id)" {"id": "col/123"}

func DirectivesFromContext

func DirectivesFromContext(ctx context.Context) (directives []string, found bool)

func Dot

func Dot(parts ...string) string

Dot joins a slice of strings with a dot

func DoubleQuote

func DoubleQuote(s string) string

DoubleQuote ...

func Enforce

func Enforce[T proto.Message](ctx context.Context, enforcer casbin.IEnforcer, accountFn AccountFn[T], enforceFn EnforceFn[T]) (subject T, authorized bool)

Enforce is a helper function to enforce a policy

func Enforcer

func Enforcer(conf, policy string) func() (*casbin.Enforcer, error)

Enforcer is a helper function to provide a casbin enforcer

func Expose

func Expose[T proto.Message](_ T) exposed

Expose ...

func FOR

func FOR[T proto.Message](filter Filters) (q string, bindVars map[string]interface{})

FOR returns documents from a collection

Example: "FOR doc IN col FILTER doc.name == @name RETURN doc" {"name": "John"}

func Filter

func Filter(exprs ...string) filters

Filter ...

func FilterFrom

func FilterFrom[T proto.Message](elem T) filters

FilterFrom ...

func GEO_POINT added in v0.14.4

func GEO_POINT(value *typesv1.Point) map[string]interface{}

func GEO_POLYGON added in v0.14.4

func GEO_POLYGON(value *typesv1.Polygon) map[string]interface{}

func GraphqlMiddleware

func GraphqlMiddleware(next http.Handler) http.Handler

GraphqlMiddleware injects the directives into the context

func HandleDownloadFile

func HandleDownloadFile(fs FileStorage) http.HandlerFunc

HandleDownloadFile ...

func HandleUploadFile

func HandleUploadFile(fs FileStorage) http.HandlerFunc

HandleUploadFile ...

func HashFile

func HashFile(file []byte) (string, error)

HashFile ...

func ID

func ID[T any](key string) string

NODE HELPERS

func Join

func Join(parts ...string) string

Join joins a slice of strings

func Map

func Map[T any](size int, fn func(int) T) (result []T)

Map converts a slice of values to a slice of values using a function

func Mutation

func Mutation[Arg, Out proto.Message](fn func(context.Context, Arg) (Out, error)) mutation

Mutation ...

func NewBitcoinCore

func NewBitcoinCore(ctx context.Context, config *configv1.Bitcoin, observer Observer[Topic], invoices ...*paymentv1.Invoice) *bitcoinCore

func NewConnection

func NewConnection(ctx context.Context, conf *configv1.Connection) (*connection, error)

NewConnection ...

func NewDbFileStorage

func NewDbFileStorage(access Access) (*dbFileStorage, error)

NewDbFileStorage ...

func NewEnforcer

func NewEnforcer(conf, policy string) (*casbin.Enforcer, error)

func NewFilesystemStorage

func NewFilesystemStorage(config *configv1.FilesystemStorage) (*filesystemStorage, error)

NewFilesystemStorage ...

func NewGraph

func NewGraph() *graph

NewGraph ...

func NewObserver

func NewObserver[T comparable]() *observer[T]

NewObserver ...

func OTPSubscriber added in v0.16.8

func OTPSubscriber(ctx context.Context, config *configv1.Mail, mailTemplate, smsTemplate OTPTemplate) (Topic, Processor[Topic])

OTPSubscriber is a function that sends an email to the user with the OTP code

func ProtoMarshal

func ProtoMarshal(v any, out proto.Message) error

func Provide

func Provide[T any](val any) fx.Option

Provide provides a value annotated with a specific type

func Pure

func Pure[T any](v T) (result T)

Pure converts a value to a pure JSON value

func Query

func Query[Arg, Out proto.Message](fn func(context.Context, Arg) (Out, error)) query

Query ...

func QueryJoin

func QueryJoin(parts ...string) string

QueryJoin joins a slice of strings with a space

func Quote

func Quote(s string) string

Quote ...

func REMOVE

func REMOVE[T proto.Message](filters Filters) (q string, bindVars map[string]interface{})

REMOVE removes documents from a collection

Example: "FOR doc IN col FILTER doc.name == @name REMOVE doc IN col" {"name": "John"}

func ReadReset

func ReadReset(r *http.Request) ([]byte, error)

ReadReset reads and returns the full body of the request without consuming it permanently. It restores the body so it can be read again later. Returns an error if reading fails or body exceeds MaxBodySize.

func Select

func Select[T any](v T) selector[T]

Select returns a new selector with the given value

func SessionFromContext

func SessionFromContext(ctx context.Context) (session *authv1.Session, found bool)

func Should

func Should[T any](v T, _ error) T

Should returns a value and ignores the error

func Subject

func Subject(contact *domainv1.Contact) string

func ToMap

func ToMap(v any) (result map[string]any)

ToMap converts a value to a map[string]any

func ValueOfEnum

func ValueOfEnum(enum protoreflect.EnumDescriptor, name string) protoreflect.Value

Types

type Access

type Access interface {
	// AutoMigrate ...
	AutoMigrate(ctx context.Context, graph Graph) error

	// Collection ...
	Collection(ctx context.Context, elem any, callbacks ...func(context.Context, driver.Collection)) (driver.Collection, error)

	// Query returns a list of elements
	Query(ctx context.Context, query string, bindVars map[string]any, out any) error

	// Fetch returns a single element
	Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error

	// List ...
	List(ctx context.Context, filters Filters, out any) (int64, error)

	// Get ...
	Get(ctx context.Context, filters Filters, out any) error

	// Create ...
	Create(ctx context.Context, val any) ([]string, error)

	// Update ...
	Update(ctx context.Context, key string, item any) error

	// Replace ...
	Replace(ctx context.Context, key string, item any) error

	// Delete ...
	Delete(ctx context.Context, item any) error

	// Relations ...
	Relations(ctx context.Context, id string, filters Filters, direction Direction, out any) (int64, error)
}

Access ...

type AccountFn added in v0.18.0

type AccountFn[T proto.Message] func(ctx context.Context, session *domainv1.Session) (T, error)

AccountFn is a function that returns a value and an error

type ArangoAccess

type ArangoAccess struct {
	// contains filtered or unexported fields
}

func NewArangoAccess

func NewArangoAccess(conn Connection, observer Observer[Topic]) (*ArangoAccess, error)

func (*ArangoAccess) AutoMigrate

func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph Graph) error

AutoMigrate ...

func (*ArangoAccess) Collection

func (e *ArangoAccess) Collection(ctx context.Context, elem any, callbacks ...func(context.Context, driver.Collection)) (col driver.Collection, err error)

Collection ...

func (*ArangoAccess) Create

func (e *ArangoAccess) Create(ctx context.Context, val any) ([]string, error)

Create ...

func (*ArangoAccess) Delete

func (e *ArangoAccess) Delete(ctx context.Context, item any) error

Delete ...

func (*ArangoAccess) Fetch

func (e *ArangoAccess) Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error

Fetch ...

func (*ArangoAccess) Get

func (e *ArangoAccess) Get(ctx context.Context, filters Filters, out any) error

Get ...

func (*ArangoAccess) List

func (e *ArangoAccess) List(ctx context.Context, filters Filters, out any) (int64, error)

List ...

func (*ArangoAccess) Query

func (e *ArangoAccess) Query(ctx context.Context, query string, bindVars map[string]any, out any) error

Query ...

func (*ArangoAccess) Relations

func (e *ArangoAccess) Relations(ctx context.Context, id string, filters Filters, direction Direction, out any) (int64, error)

Relations ...

func (*ArangoAccess) Replace

func (e *ArangoAccess) Replace(ctx context.Context, key string, item any) error

Replace ...

func (*ArangoAccess) Update

func (e *ArangoAccess) Update(ctx context.Context, key string, item any) error

Update ...

type AuthHandler

type AuthHandler struct {
	authv1.UnsafeAuthenticationServiceServer
	authv1.UnsafeClientServiceServer
	// contains filtered or unexported fields
}

func NewAuthHandler

func NewAuthHandler(ctx context.Context, config *configv1.Auth, params AuthHandlerParams) (*AuthHandler, error)

func (*AuthHandler) Config added in v0.18.6

Config implements [authv1.ClientServiceServer].

func (*AuthHandler) FetchAccessToken added in v0.18.6

func (h *AuthHandler) FetchAccessToken(ctx context.Context, req *emptypb.Empty) (*authv1.AuthResponse, error)

FetchAccessToken implements [authv1.AuthenticationServiceServer].

func (*AuthHandler) FetchSession added in v0.18.6

func (h *AuthHandler) FetchSession(ctx context.Context, req *emptypb.Empty) (*authv1.FetchSessionResponse, error)

FetchSession implements [authv1.AuthenticationServiceServer].

func (*AuthHandler) Handler

func (h *AuthHandler) Handler(ctx context.Context) http.Handler

func (*AuthHandler) Logout added in v0.16.4

func (h *AuthHandler) Logout(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)

func (*AuthHandler) Middleware

func (h *AuthHandler) Middleware(next http.Handler) http.Handler

func (*AuthHandler) RequestNonce added in v0.15.0

RequestNonce implements [authv1.AuthenticationServiceServer].

func (*AuthHandler) RequestOTP

RequestOTP implements [authv1.AuthenticationServiceServer].

func (*AuthHandler) RuntimeMiddleware added in v0.18.0

func (h *AuthHandler) RuntimeMiddleware(next runtime.HandlerFunc) runtime.HandlerFunc

func (*AuthHandler) VerifyNonce added in v0.15.0

VerifyNonce implements [authv1.AuthenticationServiceServer]. It verifies an Ethereum personal_sign (EIP-191) signature over the nonce we issued for the address, then issues JWT tokens for the session.

func (*AuthHandler) VerifyOTP

type AuthHandlerParams

type AuthHandlerParams struct {
	fx.In

	Access   Access
	Observer Observer[Topic]
}

type BitcoinPaymentGateway

type BitcoinPaymentGateway struct {
	bitcoinv1.UnsafeBitcoinPaymentServiceServer
	bitcoinv1.UnsafeBitcoinPaymentDashboardServiceServer
	// contains filtered or unexported fields
}

func (*BitcoinPaymentGateway) CreateInvoice

func (*BitcoinPaymentGateway) DashboardHandler added in v0.19.0

func (h *BitcoinPaymentGateway) DashboardHandler(ctx context.Context, auth *AuthHandler, dashboard *DashboardHandler) http.Handler

func (*BitcoinPaymentGateway) Export

func (*BitcoinPaymentGateway) GetInvoice

func (*BitcoinPaymentGateway) Handler

func (*BitcoinPaymentGateway) ListInvoices

func (*BitcoinPaymentGateway) Ping

func (*BitcoinPaymentGateway) RefreshInvoice

func (*BitcoinPaymentGateway) Subscribe

func (h *BitcoinPaymentGateway) Subscribe(w http.ResponseWriter, r *http.Request, pathParams map[string]string)

type BitcoinPaymentGatewayParams

type BitcoinPaymentGatewayParams struct {
	fx.In

	Access   Access
	Observer Observer[Topic]
}

type CasbinAdapter

type CasbinAdapter[T proto.Message] struct {
	// contains filtered or unexported fields
}

CasbinAdapter ...

func Unsafe_NewCasbinAdapter

func Unsafe_NewCasbinAdapter[T proto.Message](ctx context.Context, access Access) (*CasbinAdapter[T], error)

Unsafe_NewCasbinAdapter ... TODO: finish this

func (*CasbinAdapter[T]) AddPolicy

func (a *CasbinAdapter[T]) AddPolicy(sec string, ptype string, rule []string) error

AddPolicy implements persist.Adapter.

func (*CasbinAdapter[T]) ExtraFields

func (a *CasbinAdapter[T]) ExtraFields() (result []protoreflect.FieldDescriptor)

func (*CasbinAdapter[T]) LoadPolicy

func (a *CasbinAdapter[T]) LoadPolicy(model model.Model) error

LoadPolicy implements persist.Adapter.

func (*CasbinAdapter[T]) Marshal

func (a *CasbinAdapter[T]) Marshal(elem T) (sec string, ptype string, rule []string)

func (*CasbinAdapter[T]) RemoveFilteredPolicy

func (a *CasbinAdapter[T]) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy implements persist.Adapter.

func (*CasbinAdapter[T]) RemovePolicy

func (a *CasbinAdapter[T]) RemovePolicy(sec string, ptype string, rule []string) error

RemovePolicy implements persist.Adapter.

func (*CasbinAdapter[T]) SavePolicy

func (a *CasbinAdapter[T]) SavePolicy(model model.Model) error

SavePolicy implements persist.Adapter.

func (*CasbinAdapter[T]) Unmarshal

func (a *CasbinAdapter[T]) Unmarshal(sec string, ptype string, rule []string) (out T, err error)

type Checks

type Checks[T any] []func(T) bool

Checks is a collection of functions that can be used to check if a key should be ignored

func (Checks[T]) All

func (c Checks[T]) All(key T) bool

All returns true if all of the checks return true

func (Checks[T]) Any

func (c Checks[T]) Any(key T) bool

Any returns true if any of the checks return true

type Comparer

type Comparer interface {
	Symbol() string
	Value() interface{}
}

Comparer is a type that represents a comparison operator and its value.

type Config added in v0.13.11

type Config struct {
	fx.In

	Router      *configv1.Router
	Middlewares []Middleware `group:"middlewares"`
}

type Connection

type Connection interface {
	// Database ...
	Database(ctx context.Context) (driver.Database, error)
	// Collection ...
	Collection(ctx context.Context, elem any) (driver.Collection, error)
	// Reflect ...
	Reflect(ctx context.Context, elem reflect.Type) (driver.Collection, error)
}

Connection ...

type DashboardHandler

DashboardHandler ...

func NewDashboard

func NewDashboard(ctx context.Context, config *configv1.Dashboard, auth *AuthHandler, params DashboardParams) (*DashboardHandler, error)

NewDashboard ...

func (*DashboardHandler) DeleteAccount

func (*DashboardHandler) DeleteResource

func (*DashboardHandler) GetAccount

func (*DashboardHandler) GetCurrentAccount added in v0.18.0

func (*DashboardHandler) GetResource

func (*DashboardHandler) GetSchema

func (*DashboardHandler) Handler

func (h *DashboardHandler) Handler(ctx context.Context, auth *AuthHandler) http.Handler

func (*DashboardHandler) ListAccounts

func (*DashboardHandler) RuntimeMiddleware added in v0.19.0

func (h *DashboardHandler) RuntimeMiddleware(next runtime.HandlerFunc) runtime.HandlerFunc

func (*DashboardHandler) UpdateScopes

func (*DashboardHandler) UpdateStatus

type DashboardParams

type DashboardParams struct {
	fx.In

	Access
	Graph
	FileStorage
	Observer[Topic]
}

DashboardParams ...

type Definition added in v0.15.1

type Definition string

Definition is a type that represents a definition.

type Direction

type Direction int

Direction is a direction of a relation.

INBOUND: the relation is inbound to the node, means the node is the target of the relation.

OUTBOUND: the relation is outbound from the node, means the node is the source of the relation.

ANY: the relation is inbound or outbound from the node, means the node is the source or target of the relation.

const (
	DirectionInbound Direction = iota
	DirectionOutbound
	DirectionAny
)

func (Direction) String

func (d Direction) String() string

type EnforceFn

type EnforceFn[T proto.Message] func(ctx context.Context, subject T) (Rules, error)

EnforceFn is a function that returns a slice of any and an error

type Eq

type Eq struct {
	To any
}

Eq supports the == operator

func (Eq) Symbol

func (Eq) Symbol() string

func (Eq) Value

func (e Eq) Value() interface{}

type Event

type Event[T comparable] struct {
	// Topic ...
	Topic T
	// Payload ...
	Payload protoreflect.ProtoMessage
	// Timestamp ...
	Timestamp time.Time
}

Event ...

type FileStorage

type FileStorage interface {
	// StoreFile ...
	StoreFile(name string, file []byte) (id string, err error)

	// StoreByHash ...
	StoreByHash(file []byte) (id string, err error)

	// ReadFile ...
	ReadFile(id string) (fileContent []byte, errr error)

	// MaxMemory ...
	MaxMemory() int64
}

FileStorage ...

type Filters

type Filters interface {
	// FilterString ...
	FilterString(doc string) string

	// SortString ...
	SortString(doc string) string

	// LimitString ...
	LimitString() string

	// BindVars ...
	BindVars() map[string]interface{}
}

Filters ...

type Graph

type Graph interface {
	// Node ...
	Node(node any)
	// Edge ...
	Edge(from, to, edge any)

	// Nodes ...
	Nodes() []reflect.Type
	// Edges ...
	Edges() []reflect.Type
	// Relation ...
	Relation(edge reflect.Type) *Relation

	// CollectionFor ...
	CollectionFor(elem reflect.Type) string
	// TypeOf ...
	TypeOf(name string) reflect.Type
}

Graph ...

type GraphqlHandler

type GraphqlHandler struct {
	Access Access
	Graph  Graph

	fx.In
}

GraphqlHandler ...

func (*GraphqlHandler) Serve added in v0.13.8

func (e *GraphqlHandler) Serve(handlers ...interface{}) *handler.Config

Handler ...

type Gt

type Gt struct {
	Than any
}

Gt supports the > operator

func (Gt) Symbol

func (Gt) Symbol() string

func (Gt) Value

func (g Gt) Value() interface{}

type Gte

type Gte struct {
	Than any
}

Gte supports the >= operator

func (Gte) Symbol

func (Gte) Symbol() string

func (Gte) Value

func (g Gte) Value() interface{}

type Ignore added in v0.15.1

type Ignore string

type In added in v0.13.14

type In struct {
	Values any
}

func (In) Symbol added in v0.13.14

func (In) Symbol() string

func (In) Value added in v0.13.14

func (i In) Value() interface{}

type Lt

type Lt struct {
	Than any
}

Lt supports the < operator

func (Lt) Symbol

func (Lt) Symbol() string

func (Lt) Value

func (l Lt) Value() interface{}

type Lte

type Lte struct {
	Than any
}

Lte supports the <= operator

func (Lte) Symbol

func (Lte) Symbol() string

func (Lte) Value

func (l Lte) Value() interface{}

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is a function that wraps an http.Handler to add functionality before and/or after the handler is executed.

func Chain added in v0.18.0

func Chain(m ...Middleware) Middleware

func Match

func Match(re *regexp.Regexp, mw ...Middleware) Middleware

Match applies a single mux.MiddlewareFunc only if the request path matches the given regexp.

type Ne added in v0.13.14

type Ne struct {
	To any
}

Ne supports the != operator

func (Ne) Symbol added in v0.13.14

func (Ne) Symbol() string

func (Ne) Value added in v0.13.14

func (n Ne) Value() interface{}

type Nin added in v0.13.14

type Nin struct {
	Values any
}

func (Nin) Symbol added in v0.13.14

func (Nin) Symbol() string

func (Nin) Value added in v0.13.14

func (n Nin) Value() interface{}

type OTPTemplate added in v0.16.8

type OTPTemplate func(sender, code string) []byte

OTPTemplate is a function that returns the message to send to the user

type Observer

type Observer[T comparable] interface {
	// Subscribe ...
	Subscribe(t T, p Processor[T]) SourceID
	// Unsubscribe ...
	Unsubscribe(s SourceID)
	// Emit ...
	Emit(e *Event[T]) error
}

Observer ...

type Processor

type Processor[T comparable] func(e *Event[T]) error

Processor ...

type Relation

type Relation struct {
	From reflect.Type `json:"_from"`
	To   reflect.Type `json:"_to"`
}

Relation

type Rule

type Rule []interface{}

Rule is a slice of any

type Rules

type Rules []Rule

Rules is a slice of Rule

func EnforceDirectives

func EnforceDirectives(ctx context.Context, role fmt.Stringer) Rules

EnforceDirectives returns the rules for the given role for each directive

type SourceID

type SourceID int64

SourceID ...

type Topic

type Topic string
var (
	CreatedTopic  Topic = "document.created"
	UpdatedTopic  Topic = "document.updated"
	ReplacedTopic Topic = "document.replaced"
	DeletedTopic  Topic = "document.deleted"
)
var (
	ResourceCreatedTopic  Topic = "dashboard.resource.created"
	ResourceReplacedTopic Topic = "dashboard.resource.replaced"
	ResourceDeletedTopic  Topic = "dashboard.resource.deleted"
)
var (
	CreateInvoiceTopic Topic = "invoice.create"
	UpdateInvoiceTopic Topic = "invoice.update"
)

func (Topic) For

func (t Topic) For(elem any) Topic

func (Topic) Tag

func (t Topic) Tag(tag, val string) Topic

Directories

Path Synopsis
examples
library command
internal
pkg
auth/domain/auth/v1
Package authv1 is a reverse proxy.
Package authv1 is a reverse proxy.
dashboard/domain/dashboard/v1
Package dashboardv1 is a reverse proxy.
Package dashboardv1 is a reverse proxy.
payment/domain/bitcoin/v1
Package bitcoinv1 is a reverse proxy.
Package bitcoinv1 is a reverse proxy.

Jump to

Keyboard shortcuts

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