mirror of
https://github.com/karust/openserp.git
synced 2026-08-05 16:53:54 +08:00
29 lines
713 B
Go
29 lines
713 B
Go
|
|
package core
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"strings"
|
||
|
|
)
|
||
|
|
|
||
|
|
type profileContextKey string
|
||
|
|
|
||
|
|
const profileRegionContextKey profileContextKey = "profile_region"
|
||
|
|
|
||
|
|
func WithProfileRegion(ctx context.Context, region string) context.Context {
|
||
|
|
region = strings.TrimSpace(region)
|
||
|
|
if region == "" {
|
||
|
|
return EnsureContext(ctx)
|
||
|
|
}
|
||
|
|
return context.WithValue(EnsureContext(ctx), profileRegionContextKey, region)
|
||
|
|
}
|
||
|
|
|
||
|
|
func profileRegionFromContext(ctx context.Context) string {
|
||
|
|
value, _ := EnsureContext(ctx).Value(profileRegionContextKey).(string)
|
||
|
|
return strings.TrimSpace(value)
|
||
|
|
}
|
||
|
|
|
||
|
|
func engineFromContext(ctx context.Context) string {
|
||
|
|
value, _ := EnsureContext(ctx).Value(engineContextKey).(string)
|
||
|
|
return strings.TrimSpace(value)
|
||
|
|
}
|