memostream

package
v0.0.0-...-eeddc09 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: GPL-3.0 Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Media_File        MediaProtocol = 0
	Media_Redirect    MediaProtocol = 1
	Media_Proxy       MediaProtocol = 2
	Media_ProxyDirect MediaProtocol = 3

	Media_Public  MediaAccess = 0
	Media_Private MediaAccess = 1

	Media_OK    MediaStatus = 0
	Media_Error MediaStatus = 1
	Media_New               = 2
)

Variables

View Source
var (
	// conversion string to protocol
	MediaProtocolString = map[string]MediaProtocol{
		"file":        Media_File,
		"redirect":    Media_Redirect,
		"proxy":       Media_Proxy,
		"proxydirect": Media_ProxyDirect,
	}
	// conversion protocol number to string
	MediaProtocolNum = map[MediaProtocol]string{
		Media_File:        "file",
		Media_Redirect:    "redirect",
		Media_Proxy:       "proxy",
		Media_ProxyDirect: "proxydirect",
	}

	// conversion string to access type
	MediaAccessString = map[string]MediaAccess{
		"public": Media_Public,
		"closed": Media_Private,
	}
	// conversion access number to access string
	MediaAccessNum = map[MediaAccess]string{
		Media_Public:  "public",
		Media_Private: "closed",
	}

	MediaStatusString = map[string]MediaStatus{
		"ok":    Media_OK,
		"error": Media_Error,
		"new":   Media_New,
	}
	MediaStatusNum = map[MediaStatus]string{
		Media_OK:    "ok",
		Media_Error: "error",
		Media_New:   "new",
	}
)
View Source
var (
	VERSION string = "Memoriav Mediaserver 0.1"
)

Functions

func CheckJWT

func CheckJWT(tokenstring string, secret string, alg []string, subject string, subClaim string) error

func CheckRequestJWT

func CheckRequestJWT(req *http.Request, secret string, alg []string, subject string, subClaim string) error

func CreateLogger

func CreateLogger(module string, logfile string, loglevel string) (log *logging.Logger, lf *os.File)

func FileExists

func FileExists(filename string) bool

func NameFromUri

func NameFromUri(uri url.URL) string

extracts last part of uri as name

func NewJWT

func NewJWT(secret string, subject string, alg string, valid int64, domain string, issuer string) (tokenString string, err error)

func NewServer

func NewServer(
	baseUrl,
	urlPrefix,
	cmdPrefix,
	iiifPrefix,
	iiifBase,
	iiifCached,
	iiifUrl,
	iiifJwtSubPrefix,
	iiifViewerTemplate,
	iiifManifestBase,
	iiifRenderingBase,
	addr string,
	insecureProxy bool,
	resolver *ResolverCache,
	mapping *FilesystemPool,
	jwtSecret string,
	jwtAlg []string,
	log *logging.Logger,
	accesslog io.Writer,
	errorTemplate string,
	viewer map[string]string,
	staticPrefix,
	staticDir string) (*memoServer, error)

func NewTokenServiceServer

func NewTokenServiceServer(
	addr string,
	jwtSecret string,
	jwtAlg string,
	jwtValid time.Duration,
	jwtIssuer string,
	log *logging.Logger,
	accesslog io.Writer,
	errorTemplate string,
) *tokenServiceServer

func ReplaceAllStringSubmatchFunc

func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func([]string) string) string

func SingleJoiningSlash

func SingleJoiningSlash(a, b string) string

Types

type Action

type Action interface {
	// media types which are allowed for this Action
	GetType() []string
	// execute the Action
	Do(w http.ResponseWriter, req *http.Request, m *MediaEntry, action string, params ...string) (bool, error)
}

interface for a generic Action on a media object

type ActionAudio

type ActionAudio struct {
	// contains filtered or unexported fields
}

image Action using IIIF server for image manipulation

func NewActionAudio

func NewActionAudio(ms *memoServer) *ActionAudio

func (*ActionAudio) Do

func (aa *ActionAudio) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error)

func (*ActionAudio) GetType

func (aa *ActionAudio) GetType() []string

type ActionExternal

type ActionExternal struct {
	// contains filtered or unexported fields
}

image Action using IIIF server for image manipulation

func NewActionExternal

func NewActionExternal(ms *memoServer) *ActionExternal

func (*ActionExternal) Do

func (ae *ActionExternal) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error)

func (*ActionExternal) GetType

func (ae *ActionExternal) GetType() []string

type ActionIIIFManifest

type ActionIIIFManifest struct {
	// contains filtered or unexported fields
}

image Action using IIIF server for image manipulation

func NewActionIIIFManifest

func NewActionIIIFManifest(ms *memoServer) *ActionIIIFManifest

func (*ActionIIIFManifest) Do

func (am *ActionIIIFManifest) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error)

func (*ActionIIIFManifest) GetType

func (am *ActionIIIFManifest) GetType() []string

type ActionImageIIIF

type ActionImageIIIF struct {
	// contains filtered or unexported fields
}

image Action using IIIF server for image manipulation

func NewActionImageIIIF

func NewActionImageIIIF(ms *memoServer) *ActionImageIIIF

func (*ActionImageIIIF) Do

func (iai *ActionImageIIIF) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error)

func (*ActionImageIIIF) GetType

func (iai *ActionImageIIIF) GetType() []string

type ActionMaster

type ActionMaster struct {
	// contains filtered or unexported fields
}

image Action using IIIF server for image manipulation

func NewActionMaster

func NewActionMaster(ms *memoServer) *ActionMaster

func (*ActionMaster) Do

func (am *ActionMaster) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error)

func (*ActionMaster) GetType

func (am *ActionMaster) GetType() []string

type ActionVideo

type ActionVideo struct {
	// contains filtered or unexported fields
}

image Action using IIIF server for image manipulation

func NewActionVideo

func NewActionVideo(ms *memoServer) *ActionVideo

func (*ActionVideo) Do

func (av *ActionVideo) Do(w http.ResponseWriter, req *http.Request, me *MediaEntry, action string, params ...string) (bool, error)

func (*ActionVideo) GetType

func (av *ActionVideo) GetType() []string

type Filesystem

type Filesystem interface {
	// creates ReadSeekerCloser, returns last modification time
	Open(uri url.URL) (ReadSeekerCloser, time.Time, error)

	// checks existence of uri object
	Exist(uri url.URL) bool

	// builds native access path
	Truename(uri url.URL) string
}

abstraction interface for creating ReadSeekerCloser

type FilesystemDisk

type FilesystemDisk struct {
	// contains filtered or unexported fields
}

instance of Filesystem for "normal" disk filesystems

func NewFilesystemDisk

func NewFilesystemDisk(mapping map[string]string) *FilesystemDisk

constructor for FilesystemDisk

func (*FilesystemDisk) Exist

func (fm *FilesystemDisk) Exist(uri url.URL) bool

checks existence of file

func (*FilesystemDisk) Open

func (fm *FilesystemDisk) Open(uri url.URL) (ReadSeekerCloser, time.Time, error)

creates ReadSeekerCloser, returns last modification time

func (*FilesystemDisk) Truename

func (fm *FilesystemDisk) Truename(uri url.URL) string

builds native access path

type FilesystemPool

type FilesystemPool struct {
	// contains filtered or unexported fields
}

pool of filesystems

func NewFilesystemPool

func NewFilesystemPool() *FilesystemPool

constructor of FilesystemPool

func (*FilesystemPool) Exist

func (fp *FilesystemPool) Exist(uri url.URL) bool

func (*FilesystemPool) OpenUri

func (fp *FilesystemPool) OpenUri(uri url.URL) (ReadSeekerCloser, time.Time, error)

creates a ReadSeekerCloser for a specified uri from matching Filesystem

func (*FilesystemPool) SetFilesystem

func (fp *FilesystemPool) SetFilesystem(scheme string, fs Filesystem)

set a Filesystem for a specified uri scheme

func (*FilesystemPool) Truename

func (fp *FilesystemPool) Truename(uri url.URL) string

type IdleTimeoutConn

type IdleTimeoutConn struct {
	// contains filtered or unexported fields
}

connection enhancment to make sure, that unused connections will be closed afert timeout

func NewIdleTimeoutConn

func NewIdleTimeoutConn(conn net.Conn, idleTimeout time.Duration) IdleTimeoutConn

func (IdleTimeoutConn) Read

func (itc IdleTimeoutConn) Read(buf []byte) (int, error)

func (IdleTimeoutConn) Write

func (itc IdleTimeoutConn) Write(buf []byte) (int, error)

type MediaAccess

type MediaAccess int

type MediaEntry

type MediaEntry struct {
	Signature               string
	URI                     url.URL
	Protocol                MediaProtocol
	Access                  MediaAccess
	Status                  MediaStatus
	Type                    string
	Mimetype                string
	Width, Height, Duration int64
	ManifestV2, ManifestV3  string
}

Represents the data needed to stream media object

func NewMediaEntry

func NewMediaEntry(signature, uri, access, protocol, status, t, mimetype string, width, height, length int64, manifestV2, manifestV3 string) (*MediaEntry, error)

type MediaProtocol

type MediaProtocol int

protocol and access types need to be enums

type MediaStatus

type MediaStatus int

type ReadSeekerCloser

type ReadSeekerCloser interface {
	io.ReadCloser
	io.Seeker
}

io.ReadCloser with io.seeker for http.ServeContent

type ResolverCache

type ResolverCache struct {
	// contains filtered or unexported fields
}

the ResolvarCache contains the database resolver and a caching structure

func NewResolver

func NewResolver(r ResolverDB, cacheSize int, cachetimeout time.Duration) *ResolverCache

create a new ResolverCache todo: expiration konfigurierbar

func (*ResolverCache) ClearCache

func (r *ResolverCache) ClearCache()

if data changes, we have to clear the cache to prevent the use of old content

func (*ResolverCache) TestData

func (r *ResolverCache) TestData(mediatype, access string, num int64) ([]*MediaEntry, error)

type ResolverDB

type ResolverDB interface {
	Resolve(signature string) (*MediaEntry, error)
	TestData(mediatype, access string, num int64) ([]*MediaEntry, error)
	Close()
}

for a type to be a ResolverDB there must be a function for resolving a signature and a close function for shtutdown

type ResolverDBMySQL

type ResolverDBMySQL struct {
	// contains filtered or unexported fields
}

resolver for MySQL database (should work with PostGreSQL too)

func NewResolverDBMysql

func NewResolverDBMysql(db *sql.DB, query string) (*ResolverDBMySQL, error)

create new ResolverDBMySQL

func (*ResolverDBMySQL) Close

func (rdm *ResolverDBMySQL) Close()

shutdown resolver

func (*ResolverDBMySQL) Init

func (rdm *ResolverDBMySQL) Init() (err error)

initializes ResolverDBMySQL

func (*ResolverDBMySQL) Resolve

func (rdm *ResolverDBMySQL) Resolve(signature string) (*MediaEntry, error)

resolve MediaEntry for signature

func (*ResolverDBMySQL) TestData

func (rdm *ResolverDBMySQL) TestData(mediatype, access string, num int64) ([]*MediaEntry, error)

type ResolverDBStatic

type ResolverDBStatic struct {
	// contains filtered or unexported fields
}

* Static resolver for testing the memoServer functionality

func NewResolverDBStatic

func NewResolverDBStatic(signatures map[string]Sig) *ResolverDBStatic

func (*ResolverDBStatic) Close

func (rds *ResolverDBStatic) Close()

func (*ResolverDBStatic) Resolve

func (rds *ResolverDBStatic) Resolve(signature string) (*MediaEntry, error)

func (*ResolverDBStatic) TestData

func (rds *ResolverDBStatic) TestData(mediatype, access string, num int64) ([]*MediaEntry, error)

type Sig

type Sig struct {
	Type   string
	Uri    string
	Access string
}

Jump to

Keyboard shortcuts

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