pinterface

package module
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-3-Clause Imports: 1 Imported by: 47

README

pinterface

Go Report Card License

Interface types for simple* and permission* packages.

Interfaces for:

Packaging status

General information

  • Version: 1.5.3 (The tag is v1.5.3 to work better with go mod. The API has version 5.3.)
  • License: BSD-3
  • Author: Alexander F. Rødseth <xyproto@archlinux.org>

Documentation

Overview

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

Index

Constants

View Source
const Version = 5.3

Version is the API version. The API is stable within the same major version number

Variables

This section is empty.

Functions

This section is empty.

Types

type ICreator

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

Data structure creator

type IHashMap

type IHashMap interface {
	All() ([]string, error)
	Clear() error
	DelKey(owner, key string) error
	Del(key string) error
	Exists(owner string) (bool, error)
	Get(owner, key string) (string, error)
	Has(owner, key string) (bool, error)
	Keys(owner string) ([]string, error)
	Remove() error
	Set(owner, key, value string) error
}

type IHashMap2

type IHashMap2 interface {
	All() ([]string, error)
	AllWhere(key, value string) ([]string, error)
	Clear() error
	Count() (int64, error)
	DelKey(owner, key string) error
	Del(key string) error
	Empty() (bool, error)
	Exists(owner string) (bool, error)
	GetMap(owner string, keys []string) (map[string]string, error)
	Get(owner, key string) (string, error)
	Has(owner, key string) (bool, error)
	Keys(owner string) ([]string, error)
	Remove() error
	SetLargeMap(all map[string]map[string]string) error
	SetMap(owner string, m map[string]string) error
	Set(owner, key, value string) error
}

type IHost

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

Database host (or file)

type IKeyValue

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

type IList

type IList interface {
	Add(value string) error
	All() ([]string, error)
	Clear() error
	LastN(n int) ([]string, error)
	Last() (string, error)
	Remove() error
}

type IPermissions

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

Middleware for permissions

type IRedisCreator

type IRedisCreator interface {
	SelectDatabase(dbindex int)
}

Redis data structure creator

type IRedisHost

type IRedisHost interface {
	DatabaseIndex()
	Pool()
}

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

type ISet

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

type IUserState

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

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

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