middleware

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2019 License: GPL-3.0 Imports: 13 Imported by: 9

Documentation

Index

Constants

View Source
const ContainerKey = "container"

ContainerKey is used to retrieve the container out of the request context. This can either be a user or a group.

View Source
const PreviousKey = "previous"
View Source
const ProjectKey = "project"

ProjectKey is used to retrieve a project from a request context.

View Source
const ProtocolKey = "protocol"
View Source
const TestCaseKey = "testcase"

TestCaseKey is used to retrieve a testcase from a request context.

View Source
const TestSequenceKey = testSequenceKey("testsequence")

TestSequenceKey can be used to retrieve a testsequence from a request context.

View Source
const UserKey = "user"

UserKey is used to retrieve the currently signed in user from the request context (nil if no user is signed in).

Variables

This section is empty.

Functions

func AddToContext

func AddToContext(r *http.Request, key, value interface{})

AddToContext adds a value to given request context.

func Auth

func Auth(session SessionHandler) negroni.HandlerFunc

Auth returns a middleware that will check the user session for the signed in user. The retrieved user will be written into the request context with the key "user"

func CaseProtocol added in v1.4.0

func CaseProtocol(store CaseProtocolStore) negroni.HandlerFunc

CaseProtocol is a middleware that can retrieve a protocol from a request. It requires the container, the project and the testcase middleware to work.

func Container

func Container(user UserRetriever, group GroupRetriever) negroni.HandlerFunc

Container returns a middleware that will get the container for a project from a request. For this to work

func Project

func Project(store ProjectStore) negroni.HandlerFunc

Project returns a middleware that retrieves a project from a request and injects it into the request context. It requires the 'project' parameter containing the id of the project and the container middleware.

func SequenceProtocol added in v1.4.0

func SequenceProtocol(store SequenceProtocolStore) negroni.HandlerFunc

SequenceProtocol is a middleware that can retrieve a protocol from a request. It requires the container, the project and the testcase middleware to work.

func TestSequence

func TestSequence(store TestSequenceStore) negroni.HandlerFunc

TestSequence is a middleware that can retrieve a testsequence from a request it requires the project as well as the container middleware to work.

func Testcase

func Testcase(store TestCaseStore) negroni.HandlerFunc

Testcase is a middleware that can retrieve a testcase from a request it requires the project as well as the container middleware to work.

Types

type CaseProtocolStore added in v1.4.0

type CaseProtocolStore interface {
	// GetCaseExecutionProtocols gets the protocols for the testcase with given id,
	// which is part of the project with given id.
	GetCaseExecutionProtocols(testcaseID id.TestID) ([]test.CaseExecutionProtocol, error)
}

CaseProtocolStore provides an interface for retrieving both case and sequence protocols

type GroupRetriever

type GroupRetriever interface {

	// Get returns the group with the given name
	Get(groupID id.ActorID) (*group.Group, bool, error)
}

GroupRetriever is used to get a group by name.

type ProjectStore

type ProjectStore interface {

	// Get looks up the project with the given id. It returns a pointer to the project and true
	// if a matching project was found or nil and false otherwise
	Get(projectID id.ProjectID) (*project.Project, bool, error)
}

ProjectStore provides an interface for retrieving projects

type SequenceProtocolStore added in v1.4.0

type SequenceProtocolStore interface {
	// GetSequenceExecutionProtocols gets the protocols for the testsequence with given id,
	// which is part of the project with given id.
	GetSequenceExecutionProtocols(sequenceID id.TestID) ([]test.SequenceExecutionProtocol, error)
}

SequenceProtocolStore provides an interface for retrieving sequence protocols

type SessionHandler

type SessionHandler interface {
	// GetCurrent gets the user that hold the session. If there is no
	// user session the returned user will be nil.
	GetCurrent(r *http.Request) (*user.User, error)
}

SessionHandler is used to get the user that corresponds to a request.

type TestCaseStore

type TestCaseStore interface {
	// Get returns the test case with the given ID for the given project under the given container
	Get(caseID id.TestID) (*test.Case, bool, error)
}

TestCaseStore provides an interface for retrieving testcases

type TestSequenceStore

type TestSequenceStore interface {

	// Get returns the test case with the given ID for the given project under the given container
	Get(sequenceID id.TestID) (*test.Sequence, bool, error)
}

TestSequenceStore provides an interface for retrieving sequence

type UserRetriever

type UserRetriever interface {

	// Get returns the user with the given ID
	Get(userID id.ActorID) (*user.User, bool, error)
}

UserRetriever is used to get a user by id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL