store

package
v0.0.0-...-cd6e81f Latest Latest
Warning

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

Go to latest
Published: May 6, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRedirectNotFound gets returned if a redirect can't be found on the store.
	ErrRedirectNotFound = fmt.Errorf("Failed to find a redirect")

	// ErrRedirectSourceExists gets returned if a redirect s source already exists.
	ErrRedirectSourceExists = fmt.Errorf("Source already exists")
)

Functions

func CreateRedirect

func CreateRedirect(c context.Context, record *model.Redirect) error

CreateRedirect creates a redirect on the store.

func DeleteRedirect

func DeleteRedirect(c context.Context, id string) error

DeleteRedirect deletes a redirect from the store.

func GetRedirect

func GetRedirect(c context.Context, id string) (*model.Redirect, error)

GetRedirect retrieves a specific redirect from the store.

func GetRedirects

func GetRedirects(c context.Context) ([]*model.Redirect, error)

GetRedirects retrieves all redirects from the store.

func ToContext

func ToContext(c Setter, store Store)

ToContext injects the store into the context.

func UpdateRedirect

func UpdateRedirect(c context.Context, record *model.Redirect) error

UpdateRedirect updates a redirect on the store.

Types

type Setter

type Setter interface {
	Set(string, interface{})
}

Setter defines a context that enables setting values.

type Store

type Store interface {
	// Name simply returns the name of the store implementation.
	Name() string

	// Config just returns a simple configuration explanation.
	Config() string

	// GetRedirects retrieves all redirects from the store.
	GetRedirects() ([]*model.Redirect, error)

	// GetRedirect retrieves a specific redirect from the store.
	GetRedirect(string) (*model.Redirect, error)

	// DeleteRedirect deletes a redirect from the store.
	DeleteRedirect(string) error

	// CreateRedirect creates a redirect on the store.
	CreateRedirect(*model.Redirect) error

	// UpdateRedirect updates a redirect on the store.
	UpdateRedirect(*model.Redirect) error
}

Store implements all required data-layer functions for Redirects.

func FromContext

func FromContext(c context.Context) Store

FromContext gets the store from the context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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