Skip to content

Commit

Permalink
修改
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuwenliang committed Jul 22, 2024
1 parent 0db346f commit f79b079
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion internal/pkg/ectx/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}
8 changes: 3 additions & 5 deletions internal/pkg/middleware/check_appid_builder.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -13,9 +14,8 @@ import (
type CheckAppIdBuilder struct {
}


const (
appIDHeader = "app"
appIDHeader = "app"
)

func NewCheckAppIdBuilder() *CheckAppIdBuilder {
Expand All @@ -39,5 +39,3 @@ func (a *CheckAppIdBuilder) Build() gin.HandlerFunc {
ctx.Request = ctx.Request.WithContext(newCtx)
}
}


3 changes: 2 additions & 1 deletion internal/pkg/middleware/check_appid_builder_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion internal/user/internal/integration/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions internal/user/internal/repository/dao/user_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dao
import (
"context"
"fmt"

"github.com/ecodeclub/webook/internal/pkg/ectx"

"github.com/ecodeclub/webook/internal/pkg/snowflake"
Expand Down

0 comments on commit f79b079

Please sign in to comment.