Skip to content

Commit

Permalink
Export functions
Browse files Browse the repository at this point in the history
  • Loading branch information
klaidliadon committed Oct 25, 2024
1 parent 733cff5 commit ed35ec3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func GetSessionType(ctx context.Context) (proto.SessionType, bool) {
// Account
//

// withAccount adds the account to the context.
func withAccount(ctx context.Context, account string) context.Context {
// WithAccount adds the account to the context.
func WithAccount(ctx context.Context, account string) context.Context {
return context.WithValue(ctx, ctxKeyAccount, account)
}

Expand Down Expand Up @@ -90,8 +90,8 @@ func GetService(ctx context.Context) (string, bool) {
// AccessKey
//

// withAccessKey adds the access key to the context.
func withAccessKey(ctx context.Context, accessKey string) context.Context {
// WithAccessKey adds the access key to the context.
func WithAccessKey(ctx context.Context, accessKey string) context.Context {
return context.WithValue(ctx, ctxKeyAccessKey, accessKey)
}

Expand All @@ -105,8 +105,8 @@ func GetAccessKey(ctx context.Context) (string, bool) {
// Project ID
//

// withProjectID adds the project to the context.
func withProjectID(ctx context.Context, project uint64) context.Context {
// WithProjectID adds the project to the context.
func WithProjectID(ctx context.Context, project uint64) context.Context {
return context.WithValue(ctx, ctxKeyProjectID, project)
}

Expand Down
6 changes: 3 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func Session(cfg *Options) func(next http.Handler) http.Handler {
ctx = WithService(ctx, serviceClaim)
sessionType = proto.SessionType_Service
case accountClaim != "":
ctx = withAccount(ctx, accountClaim)
ctx = WithAccount(ctx, accountClaim)
sessionType = proto.SessionType_Wallet

if cfg != nil && cfg.UserStore != nil {
Expand All @@ -105,14 +105,14 @@ func Session(cfg *Options) func(next http.Handler) http.Handler {

if projectClaim > 0 {
projectID := uint64(projectClaim)
ctx = withProjectID(ctx, projectID)
ctx = WithProjectID(ctx, projectID)
sessionType = proto.SessionType_Project
}
}
}

if accessKey != "" && sessionType < proto.SessionType_Admin {
ctx = withAccessKey(ctx, accessKey)
ctx = WithAccessKey(ctx, accessKey)
sessionType = max(sessionType, proto.SessionType_AccessKey)
}

Expand Down

0 comments on commit ed35ec3

Please sign in to comment.