share

package
v0.0.0-...-779d743 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticator

func Authenticator(store Store) func(next http.Handler) http.Handler

Authenticator returns new share authentication middleware.

func BlockHandler

func BlockHandler(next http.HandlerFunc) http.HandlerFunc

BlockHandler responds with NotFound for all requests that have share in context

func VerifyHandler

func VerifyHandler(shareType module.Type, nameParam, itemParam string, next http.HandlerFunc) http.HandlerFunc

VerifyHandler verifies share from the context against name and option item parameter.

Types

type Share

type Share struct {
	Slug      string       `json:"slug"`
	Type      module.Type  `json:"type"`
	Name      string       `json:"name"`
	Items     []string     `json:"items"`
	ExpiresAt niltime.Time `json:"expires_at"`
}

Share stores share data.

func (Share) Includes

func (s Share) Includes(name, item string) bool

Includes returns true if share includes provided item.

func (Share) IsValid

func (s Share) IsValid() bool

IsValid returns true if share is valid.

type Store

type Store interface {
	// All returns all stores shares.
	All() ([]Share, error)
	// Save persists share metadata.
	Save(share *Share) error
	// Get return share metadata.
	Get(slug string) (*Share, error)
	// Remove removes share metadata.
	Remove(slug string) error
	// Expire removes all expired shares.
	Expire() error
}

Store manages share metadata.

func NewDiskStore

func NewDiskStore(dir string) (Store, error)

NewDiskStore returns a new on-disk implementation of the ShareStore.

Jump to

Keyboard shortcuts

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