forked from cortezaproject/corteza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bf4cbb
commit 34aaad7
Showing
28 changed files
with
913 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ctx | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cortezaproject/corteza-server/pkg/apigw/types" | ||
) | ||
|
||
type ContextKey string | ||
|
||
const ContextKeyScope ContextKey = "scope" | ||
|
||
func ScopeToContext(ctx context.Context, s *types.Scp) context.Context { | ||
return context.WithValue(ctx, ContextKeyScope, s) | ||
} | ||
|
||
func ScopeFromContext(ctx context.Context) *types.Scp { | ||
return ctx.Value(ContextKeyScope).(*types.Scp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package filter | ||
|
||
import ( | ||
"github.com/cortezaproject/corteza-server/pkg/apigw/types" | ||
) | ||
|
||
const ( | ||
PreFilterWeight = iota | ||
ProcesserWeight | ||
PostFilterWeight | ||
) | ||
|
||
func FilterWeight(w int, t types.FilterKind) int { | ||
mul := PreFilterWeight | ||
|
||
switch t { | ||
case types.PreFilter: | ||
mul = PreFilterWeight | ||
case types.Processer: | ||
mul = ProcesserWeight | ||
case types.PostFilter: | ||
mul = PostFilterWeight | ||
} | ||
|
||
return mul*100 + w | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.