contextkey

package
v0.0.0-...-4db77b6 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ユーザーを識別するID。認証後にコンテキストにセットされる
	ContextKeyUserID contextKey = "ctx-user-id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextReader

type ContextReader struct{}

func NewContextReader

func NewContextReader() *ContextReader

func (*ContextReader) GetUserID

func (r *ContextReader) GetUserID(ctx context.Context) (string, error)

type ContextWriter

type ContextWriter struct{}

func NewContextWriter

func NewContextWriter() *ContextWriter

func (*ContextWriter) SetUserID

func (w *ContextWriter) SetUserID(ctx context.Context, userID string) context.Context

type IContextReader

type IContextReader interface {
	// UserIDをコンテキストから取得する
	GetUserID(ctx context.Context) (string, error)
}

コンテキスト値を取得する

type IContextWriter

type IContextWriter interface {
	// UserIDをコンテキストにセットする
	SetUserID(ctx context.Context, userID string) context.Context
}

コンテキスト値をセットする

Jump to

Keyboard shortcuts

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