middleware

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2018 License: GPL-3.0 Imports: 11 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 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 = "testsequence"

TestSequenceKey is used to retrieve a testsequence from a request context.

View Source
const UserKey = "user"

UserKey is used to retrieve the currently logged in user from the request context (nil if no user is logged 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 logged in user. The retrieved user will be written into the request context with the key "user"

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 GroupRetriever

type GroupRetriever interface {

	// Get returns the group with the given ID
	Get(groupID string) (*group.Group, bool, error)
}

GroupRetriever is used to get a group by id.

type ProjectStore

type ProjectStore interface {

	// Get looks up the project with the given id in the given container. It returns a pointer to the project and true
	// if a matching project was found or nil and false otherwise
	Get(container, project string) (*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(container, project, id string) (*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(container, project, id string) (*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 string) (*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