Documentation ¶
Index ¶
- Constants
- func CtxWithHttpRequest(ctx context.Context, req *http.Request) context.Context
- func CtxWithTx(ctx context.Context, sqlConn sqlx.SqlConn) context.Context
- func DbErr(err error, msg ...string) error
- func EncodeSSEEvent(w io.Writer, e *SSEEvent) error
- func ErrHandler(ctx context.Context, err error) (int, any)
- func HostPortFromCtx(ctx context.Context) (host string, port string)
- func HttpRequestFromCtx(ctx context.Context) (*http.Request, bool)
- func InitSqlConn(cfg DatabaseConf) error
- func JwtDataAuthTokenFromCtx(ctx context.Context) string
- func JwtDataEmailFromCtx(ctx context.Context) string
- func JwtDataFromCtx(ctx context.Context) (userId int64, uid string, email string, authToken string)
- func JwtDataUidFromCtx(ctx context.Context) string
- func JwtDataUserIdFromCtx(ctx context.Context) int64
- func OkResponseHandler(ctx context.Context, v any) any
- func PingDb(ctx context.Context) error
- func RemoteAddrFromCtx(ctx context.Context) string
- func RemoveTxFromCtx(ctx context.Context) context.Context
- func TxFromCtx(ctx context.Context) (sqlConn sqlx.SqlConn, exists bool)
- func WithNewTx(ctx context.Context, fn func(context.Context, sqlx.SqlConn) error) error
- func WithTx(ctx context.Context, fn func(context.Context, sqlx.SqlConn) error) error
- func WriteJsonResponse(ctx context.Context, w http.ResponseWriter, v any, err error)
- type BootTask
- type DatabaseConf
- type SSEEvent
- type SSEStream
Constants ¶
View Source
const (
CtxKeyHttpRequest = "ctx_http_request"
)
View Source
const PostgresTxConnKey = "GoZeroPostgresTxConnKey"
Variables ¶
This section is empty.
Functions ¶
func CtxWithHttpRequest ¶
func InitSqlConn ¶
func InitSqlConn(cfg DatabaseConf) error
func JwtDataAuthTokenFromCtx ¶
func JwtDataEmailFromCtx ¶
func JwtDataFromCtx ¶
func JwtDataUidFromCtx ¶
func JwtDataUserIdFromCtx ¶
func RemoteAddrFromCtx ¶
func TxFromCtx ¶
TxFromCtx returns the transaction session from the context. If the session is not found, it returns the default connection. Return exists as false if the session is not found.
func WriteJsonResponse ¶
Types ¶
type BootTask ¶
type BootTask[T any] struct { // contains filtered or unexported fields }
func NewBootTask ¶
func (*BootTask[T]) StartAsync ¶
type DatabaseConf ¶
Click to show internal directories.
Click to hide internal directories.