pinterface

package module
v0.0.0-...-f006333 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2015 License: MIT Imports: 1 Imported by: 2

README

pinterface

Interfaces for:

General information

  • Version 2.0
  • License: MIT

Documentation

Overview

Package pinterface provides interface types for the xyproto/simple* and xyproto/permission* packages

Index

Constants

View Source
const Version = 2.0

Stable API within the same version number

Variables

This section is empty.

Functions

This section is empty.

Types

type ICreator

type ICreator interface {
	NewList(id string) (IList, error)
	NewSet(id string) (ISet, error)
	NewHashMap(id string) (IHashMap, error)
	NewKeyValue(id string) (IKeyValue, error)
}

Data structure creator

type IHashMap

type IHashMap interface {
	Put(owner, key string, value interface{}, timeout int64) error
	Set(owner, key, value string) error
	Get(owner, key string) (string, error)
	// Get(owner, key string) (interface{}, error)
	// GetString(owner, key string) (string, error)
	Has(owner, key string) (bool, error)
	Exists(owner string) (bool, error)
	GetAll() ([]string, error)
	DelKey(owner, key string) error
	Del(key string) error
	Remove() error
	Clear() error
}

type IHost

type IHost interface {
	Ping() error
	Close()
}

Database host (or file)

type IKeyValue

type IKeyValue interface {
	Set(key, value string) error
	Get(key string) (string, error)
	Del(key string) error
	Inc(key string) (string, error)
	Remove() error
	Clear() error
}

type IList

type IList interface {
	Add(value string) error
	GetAll() ([]string, error)
	GetLast() (string, error)
	GetLastN(n int) ([]string, error)
	Remove() error
	Clear() error
}

type IPermissions

type IPermissions interface {
	SetDenyFunction(f http.HandlerFunc)
	DenyFunction() http.HandlerFunc
	UserState() IUserState
	Clear()
	AddAdminPath(prefix string)
	AddUserPath(prefix string)
	AddPublicPath(prefix string)
	SetAdminPath(pathPrefixes []string)
	SetUserPath(pathPrefixes []string)
	SetPublicPath(pathPrefixes []string)
	Rejected(w http.ResponseWriter, req *http.Request) bool
	ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
}

Middleware for permissions

type IRedisCreator

type IRedisCreator interface {
	SelectDatabase(dbindex int)
}

Redis data structure creator

type IRedisHost

type IRedisHost interface {
	Pool()
	DatabaseIndex()
}

Redis host (implemented structures can also be an IHost, of course)

type ISet

type ISet interface {
	Add(value string) error
	Has(value string) (bool, error)
	GetAll() ([]string, error)
	Del(value string) error
	Remove() error
	Clear() error
}

type IUserState

type IUserState interface {
	UserRights(req *http.Request) bool
	HasUser(username string) bool
	BooleanField(username, fieldname string) bool
	SetBooleanField(username, fieldname string, val bool)
	IsConfirmed(username string) bool
	IsLoggedIn(username string) bool
	AdminRights(req *http.Request) bool
	IsAdmin(username string) bool
	UsernameCookie(req *http.Request) (string, error)
	SetUsernameCookie(w http.ResponseWriter, username string) error
	AllUsernames() ([]string, error)
	Email(username string) (string, error)
	PasswordHash(username string) (string, error)
	AllUnconfirmedUsernames() ([]string, error)
	ConfirmationCode(username string) (string, error)
	AddUnconfirmed(username, confirmationCode string)
	RemoveUnconfirmed(username string)
	MarkConfirmed(username string)
	RemoveUser(username string)
	SetAdminStatus(username string)
	RemoveAdminStatus(username string)
	AddUser(username, password, email string)
	SetLoggedIn(username string)
	SetLoggedOut(username string)
	Login(w http.ResponseWriter, username string) error
	ClearCookie(w http.ResponseWriter)
	Logout(username string)
	Username(req *http.Request) string
	CookieTimeout(username string) int64
	SetCookieTimeout(cookieTime int64)
	PasswordAlgo() string
	SetPasswordAlgo(algorithm string) error
	HashPassword(username, password string) string
	CorrectPassword(username, password string) bool
	AlreadyHasConfirmationCode(confirmationCode string) bool
	FindUserByConfirmationCode(confirmationcode string) (string, error)
	Confirm(username string)
	ConfirmUserByConfirmationCode(confirmationcode string) error
	SetMinimumConfirmationCodeLength(length int)
	GenerateUniqueConfirmationCode() (string, error)
	GetToken(username string) (string, error)
	SetToken(username string, token string, expired int64)
	RemoveToken(username string)
	SetPassword(username string, passwd string)

	Users() IHashMap
	Host() IHost
	Creator() ICreator
}

Interface for making it possible to depend on different versions of the permission package, or other packages that implement userstates.

Jump to

Keyboard shortcuts

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