Documentation ¶
Overview ¶
Package context is used to create a context that can be passed to the execution of templates. And helps with conveying information like the signed in user to the user interface.
A new context can be created using the New() function.
c := context.New()
To add information to a context use the With() function. It can be easily chained with the New() method.
c := context.New().With("key", "value").With("number", 9)
The package also provides a method with which user information is added to the context automatically. To be able to use this the packages need to get a session handler via its Init() function.
context.Init(mySessionHandler) c := context.New().WithUserInformation(myRequest)
Index ¶
Constants ¶
const ( Version = "version" // Tasks TaskList = "TaskList" TaskViewOpenedIssues = "ViewOpened" UserTaskCountList = "UserTaskCountList" // Dashboard Dashboard = "Dashboard" DashboardSequences = "DashboardSequences" // Explore Projects = "Projects" Groups = "Groups" Users = "Users" // Project Project = "Project" TestCases = "TestCases" TestSequences = "TestSequences" // Dashboard Variants = "Variants" Versions = "Versions" // TestCase TestCase = "TestCase" TestCaseVersion = "TestCaseVersion" DurationHours = "DurationHours" DurationMin = "DurationMin" DurationSec = "DurationSec" // TestSequence TestSequence = "TestSequence" TestSequenceVersion = "TestSequenceVersion" SequenceInfo = "SequenceInfo" Testers = "Testers" // Protocols SelectedTestCase = "SelectedTestCase" SelectedTestSequence = "SelectedTestSequence" SelectedType = "SelectedType" Protocol = "Protocol" CaseProtocols = "CaseProtocols" // The case protocols of a sequence ExecutionTime = "ExecutionTime" // Comments Comments = "Comments" Comment = "Comment" // Various Filtered = "Filtered" // Members Member = "Members" NonMember = "NonMembers" Owner = "Owner" // Labels LabelColors = "LabelColors" // Delete Modals DeleteLabels = "DeleteLabels" DeleteTestCase = "DeleteTestCase" DeleteTestSequence = "DeleteTestSequence" DeleteProject = "DeleteProject" // Settings SettingsIdentifier = "SettingsIdentifier" Roles = "Roles" SystemSettings = "SystemSettings" //Profile Profile = "Profile" Edit = "Edit" )
The keys for the context
const ( SignedInKey = "SignedIn" UserKey = "User" MemberKey = "Member" ProjectPermissionsKey = "ProjectPermissions" TaskCount = "TaskCount" )
Reserved keys for user information
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context map[string]interface{}
Context contains information useful for the execution of templates
func (Context) With ¶
With is a convince method used to chain-add content to the context. Values can only be added once. If a value with given key already exists this function will panic. If 'nil' is passed as data it will not be stored. This means this method can't be used to delete values.
func (Context) WithUserInformation ¶
WithUserInformation fills the context with information about the currently signed in user. This call can be chained. Be careful not to set values with the keys used by this method for the user information. (See the SignedInKey and UserKey constants of this package) If With() was used before to add values with said key this method will panic.