Help us shape the future of Go! Take the 2026 Go Developer Survey

reqctx

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppConfig

func AppConfig(c *gin.Context) *config.AppConfig

AppConfig returns the app config from the request context

func Engine

func Engine(c *gin.Context) engine.ClientInterface

Engine returns the app engine from the request context

func Logger

func Logger(c *gin.Context) *zerolog.Logger

Logger returns the app logger from the request context

func SetAppConfig

func SetAppConfig(c *gin.Context, appConfig *config.AppConfig)

SetAppConfig sets the app config in the request context

func SetEngine

func SetEngine(c *gin.Context, engine engine.ClientInterface)

SetEngine sets the app engine in the request context

func SetLogger

func SetLogger(c *gin.Context, logger *zerolog.Logger)

SetLogger sets the app logger in the request context

func SetUserContext

func SetUserContext(c *gin.Context, userContext *UserContext)

SetUserContext sets the user context in the request context

Types

type AdminContext

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

AdminContext doesn't store any significant information but help to distinguish Admin from User endpoints

func NewAdminContext

func NewAdminContext() *AdminContext

NewAdminContext creates a new AdminContext

type AuthType

type AuthType = int

AuthType is the type of authentication

const (
	// AuthTypeXPub is when user provides xPub
	AuthTypeXPub AuthType = iota

	// AuthTypeAccessKey is when user provides access key
	AuthTypeAccessKey

	// AuthTypeAdmin is when provided xpub matches the admin key
	AuthTypeAdmin
)

type UserContext

type UserContext struct {
	AuthType AuthType
	// contains filtered or unexported fields
}

UserContext is the context for the user

func GetUserContext

func GetUserContext(c *gin.Context) *UserContext

GetUserContext returns the user context from the request context

func NewUserContextAsAdmin

func NewUserContextAsAdmin() *UserContext

NewUserContextAsAdmin creates a new UserContext as an admin

func NewUserContextWithAccessKey

func NewUserContextWithAccessKey(xpubID string, xPubObj *engine.Xpub) *UserContext

NewUserContextWithAccessKey creates a new UserContext based on accessKey authorization

func NewUserContextWithPublicKeys

func NewUserContextWithPublicKeys(xpub, xpubID, publicKey, userID string) *UserContext

NewUserContextWithPublicKeys creates a new UserContext based on public keys Note: This is used for API v2 authentication only

func NewUserContextWithXPub

func NewUserContextWithXPub(xpub, xpubID string, xPubObj *engine.Xpub) *UserContext

NewUserContextWithXPub creates a new UserContext based on xpub authorization

func (*UserContext) GetAuthType

func (ctx *UserContext) GetAuthType() AuthType

GetAuthType returns the authentication type from the user context

func (*UserContext) GetXPubID

func (ctx *UserContext) GetXPubID() string

GetXPubID returns the xPubID from the user context

func (*UserContext) GetXPubObj

func (ctx *UserContext) GetXPubObj() *engine.Xpub

GetXPubObj returns an object of engine.Xpub

func (*UserContext) ShouldGetUserID

func (ctx *UserContext) ShouldGetUserID() (string, error)

ShouldGetUserID returns userID for NEW DB SCHEMA Warning: Don't use it for old DB schema

func (*UserContext) ShouldGetXPub

func (ctx *UserContext) ShouldGetXPub() (string, error)

ShouldGetXPub returns the xPub from the user context If the authentication type is not xPub, it will return an error

Jump to

Keyboard shortcuts

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