diff --git a/internal/pkg/ectx/ctx.go b/internal/pkg/ectx/ctx.go index ac2bad5c..754c7c6a 100644 --- a/internal/pkg/ectx/ctx.go +++ b/internal/pkg/ectx/ctx.go @@ -7,6 +7,7 @@ type appContextType string var ( appCtxKey appContextType = "app" ) + func GetAppIdFromCtx(ctx context.Context) (uint, bool) { app := ctx.Value(appCtxKey) if app == nil { @@ -18,4 +19,4 @@ func GetAppIdFromCtx(ctx context.Context) (uint, bool) { func CtxWithAppId(ctx context.Context, appid uint) context.Context { return context.WithValue(ctx, appCtxKey, appid) -} \ No newline at end of file +} diff --git a/internal/pkg/middleware/check_appid_builder.go b/internal/pkg/middleware/check_appid_builder.go index aab35041..e208c166 100644 --- a/internal/pkg/middleware/check_appid_builder.go +++ b/internal/pkg/middleware/check_appid_builder.go @@ -1,10 +1,11 @@ package middleware import ( - "github.com/ecodeclub/webook/internal/pkg/ectx" "net/http" "strconv" + "github.com/ecodeclub/webook/internal/pkg/ectx" + "github.com/ecodeclub/ginx" "github.com/gin-gonic/gin" "github.com/gotomicro/ego/core/elog" @@ -13,9 +14,8 @@ import ( type CheckAppIdBuilder struct { } - const ( - appIDHeader = "app" + appIDHeader = "app" ) func NewCheckAppIdBuilder() *CheckAppIdBuilder { @@ -39,5 +39,3 @@ func (a *CheckAppIdBuilder) Build() gin.HandlerFunc { ctx.Request = ctx.Request.WithContext(newCtx) } } - - diff --git a/internal/pkg/middleware/check_appid_builder_test.go b/internal/pkg/middleware/check_appid_builder_test.go index 245df81b..f6eb19e5 100644 --- a/internal/pkg/middleware/check_appid_builder_test.go +++ b/internal/pkg/middleware/check_appid_builder_test.go @@ -1,11 +1,12 @@ package middleware import ( - "github.com/ecodeclub/webook/internal/pkg/ectx" "net/http" "net/http/httptest" "testing" + "github.com/ecodeclub/webook/internal/pkg/ectx" + "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/user/internal/integration/handler_test.go b/internal/user/internal/integration/handler_test.go index 073e8079..c87d44e1 100644 --- a/internal/user/internal/integration/handler_test.go +++ b/internal/user/internal/integration/handler_test.go @@ -20,10 +20,11 @@ import ( "context" "database/sql" "fmt" - "github.com/ecodeclub/webook/internal/pkg/ectx" "net/http" "testing" + "github.com/ecodeclub/webook/internal/pkg/ectx" + "github.com/ecodeclub/webook/internal/pkg/snowflake" "github.com/ecodeclub/webook/internal/user" diff --git a/internal/user/internal/repository/dao/user_callback.go b/internal/user/internal/repository/dao/user_callback.go index 2f66968e..9ea1962f 100644 --- a/internal/user/internal/repository/dao/user_callback.go +++ b/internal/user/internal/repository/dao/user_callback.go @@ -3,6 +3,7 @@ package dao import ( "context" "fmt" + "github.com/ecodeclub/webook/internal/pkg/ectx" "github.com/ecodeclub/webook/internal/pkg/snowflake"