middleware

package
v1.3.0-rc Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: GPL-3.0 Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const CommentsKey = "Comments"

CommentsKey is used to retrieve comments from a request context.

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 ProjectKey = "project"

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

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 Comments added in v0.10.0

func Comments(store CommentStore, isCase bool) negroni.HandlerFunc

Comments is a middleware that can retrieve the comments from a request it requires the project as well as the container 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 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 CommentStore added in v0.10.0

type CommentStore interface {

	// Get returns the comments for the test case or test sequence
	// with the given ID for the given project under the given container
	Get(id id.TestID) ([]*comment.Comment, bool)
}

CommentStore provides an interface for retrieving comments

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 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 TestSequenceStoreMock added in v1.3.0

type TestSequenceStoreMock struct {
	Sequence test.Sequence
	Err      error
}

func (*TestSequenceStoreMock) Get added in v1.3.0

func (testSequenceStoreMock *TestSequenceStoreMock) Get(sequenceID id.TestID) (*test.Sequence, bool, error)

Mocked method that always returns valid results

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