mirror of
https://gitee.com/johng/gf
synced 2026-06-29 02:26:29 +08:00
inherit context from http.Request for ghttp.Request (#2550)
This commit is contained in:
11
.github/workflows/gf.yml
vendored
11
.github/workflows/gf.yml
vendored
@ -66,7 +66,9 @@ jobs:
|
||||
- 3306:3306
|
||||
|
||||
# PostgreSQL backend server.
|
||||
# docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=12345678 -e POSTGRES_USER=postgres -e POSTGRES_DB=test -v postgres:/Users/john/Temp/postgresql/data loads/postgres:13
|
||||
# docker run -d --name postgres -p 5432:5432 \
|
||||
# -e POSTGRES_PASSWORD=12345678 -e POSTGRES_USER=postgres -e POSTGRES_DB=test \
|
||||
# -v postgres:/Users/john/Temp/postgresql/data loads/postgres:13
|
||||
postgres:
|
||||
image: loads/postgres:13
|
||||
env:
|
||||
@ -84,6 +86,13 @@ jobs:
|
||||
--health-retries 5
|
||||
|
||||
# MSSQL backend server.
|
||||
# docker run -d --name mssql -p 1433:1433 \
|
||||
# -e ACCEPT_EULA=Y \
|
||||
# -e SA_PASSWORD=LoremIpsum86 \
|
||||
# -e MSSQL_DB=test \
|
||||
# -e MSSQL_USER=root \
|
||||
# -e MSSQL_PASSWORD=LoremIpsum86 \
|
||||
# loads/mssqldocker:14.0.3391.2
|
||||
mssql:
|
||||
image: loads/mssqldocker:14.0.3391.2
|
||||
env:
|
||||
|
||||
@ -26,10 +26,7 @@ func RequestFromCtx(ctx context.Context) *Request {
|
||||
// See GetCtx.
|
||||
func (r *Request) Context() context.Context {
|
||||
if r.context == nil {
|
||||
// DO NOT use the http context as it will be canceled after request done,
|
||||
// which makes the asynchronous goroutine encounter "context canceled" error.
|
||||
// r.context = r.Request.Context()
|
||||
r.context = gctx.New()
|
||||
r.context = gctx.WithCtx(r.Request.Context())
|
||||
}
|
||||
// Inject Request object into context.
|
||||
if RequestFromCtx(r.context) == nil {
|
||||
|
||||
Reference in New Issue
Block a user