govideo

package
v0.0.0-...-fd508d4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2017 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATA = iota
	SUBTITLE
)

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, error string, code int)

ErrorHandler returns HTTP response with json error message

func GenerateKey

func GenerateKey() (string, error)

GenerateKey generates 36 byte random string

func InSlice

func InSlice(slice []string, target string) bool

InSlice returns true if target string is in given slice

Types

type App

type App struct {
	*httprouter.Router
	// contains filtered or unexported fields
}

App is GoVideo Web Application TODO: add securecookie

func NewApp

func NewApp(configFile string) *App

NewApp creates new web application

func (*App) Run

func (a *App) Run()

Run starts server

func (*App) Seed

func (a *App) Seed() error

Seed seeds database

func (*App) Sync

func (a *App) Sync() error

Sync syncs database with media files media files are added uncategorized by default

type AuthClient

type AuthClient struct {
	*sessions.CookieStore // cookie session to store user info
	*MongoClient          // db client to store user info
	*RedisClient
	// contains filtered or unexported fields
}

AuthClient provides authentication

func NewAuthClient

func NewAuthClient(store *sessions.CookieStore, db *MongoClient, cache *RedisClient) (*AuthClient, error)

NewAuthClient creates new AuthClient with random key

func (*AuthClient) Authenticate

func (ac *AuthClient) Authenticate(w http.ResponseWriter, r *http.Request, email, password string) (*models.User, error)

Authenticate authenticates user with provided credentials To be called by login handler

func (*AuthClient) ClearUser

func (ac *AuthClient) ClearUser(w http.ResponseWriter, r *http.Request) error

ClearUser removes current user session

func (*AuthClient) CurUser

func (ac *AuthClient) CurUser(r *http.Request) (*models.User, error)

CurUser gets currently logged-in user

func (AuthClient) HttprouterMiddleware

func (ac AuthClient) HttprouterMiddleware(h httprouter.Handle) httprouter.Handle

HttprouterMiddleware -

func (AuthClient) Middleware

func (ac AuthClient) Middleware(h http.Handler) http.Handler

Middleware for authentication

func (AuthClient) Redirect

func (ac AuthClient) Redirect(w http.ResponseWriter, r *http.Request)

Redirect redirects to authenticate uri

type ContextKey

type ContextKey string

ContextKey -

type MongoClient

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

MongoClient holds master session and other db-related info

func NewMongoClient

func NewMongoClient(uri, dbName string) (*MongoClient, error)

NewMongoClient establishes connection to MongoDB database and returns new MongoClient object

func (*MongoClient) CreateUser

func (mc *MongoClient) CreateUser(user *models.User) error

CreateUser -

func (*MongoClient) FindMedia

func (mc *MongoClient) FindMedia(path string) (*models.Media, error)

FindMedia - recycle media after use

func (*MongoClient) GetAllMedia

func (mc *MongoClient) GetAllMedia(email string) (*models.MediaList, error)

GetAllMedia -

func (*MongoClient) GetSession

func (mc *MongoClient) GetSession() *mgo.Session

GetSession returns mgo.Session copied from MongoClient's master session Be sure to close the session after done

func (*MongoClient) GetUserFromDB

func (mc *MongoClient) GetUserFromDB(email string, hash []byte) (*models.User, error)

GetUserFromDB -

func (*MongoClient) InsertMedia

func (mc *MongoClient) InsertMedia(media *models.Media) error

InsertMedia -

func (*MongoClient) RemoveMedia

func (mc *MongoClient) RemoveMedia(mediaID string) error

RemoveMedia -

func (*MongoClient) UpdateMedia

func (mc *MongoClient) UpdateMedia(media *models.Media) error

UpdateMedia -

func (*MongoClient) UpdateSubtitle

func (mc *MongoClient) UpdateSubtitle(name, path string) error

UpdateSubtitle -

type RedisClient

type RedisClient struct {
	*redis.Pool
	// contains filtered or unexported fields
}

RedisClient -

func NewRedisClient

func NewRedisClient(config *models.Config) (*RedisClient, error)

NewRedisClient -

func (*RedisClient) ClearAuthCache

func (rc *RedisClient) ClearAuthCache(key []byte) error

ClearAuthCache clears user data from redis cache

func (*RedisClient) GetAuthCache

func (rc *RedisClient) GetAuthCache(key []byte) ([]byte, error)

GetAuthCache gets user data from redis cache

func (*RedisClient) GetEncodedPath

func (rc *RedisClient) GetEncodedPath(media *models.Media, ipAddr string) (string, error)

GetEncodedPath returns encoded path from real file path

func (*RedisClient) GetMedia

func (rc *RedisClient) GetMedia(encodedPath, ipAddr string) (*models.Media, error)

GetMedia returns Media struct from encodedPath make sure to release Media after use

func (*RedisClient) SetAuthCache

func (rc *RedisClient) SetAuthCache(userID string, data []byte) ([]byte, error)

SetAuthCache sets user data in redis cache

type StaticFileSystem

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

StaticFileSystem that disables directory listing https://groups.google.com/forum/#!topic/golang-nuts/bStLPdIVM6w

func (StaticFileSystem) Open

func (fs StaticFileSystem) Open(name string) (http.File, error)

Open only serves non-directory files

Directories

Path Synopsis
Package models is a generated protocol buffer package.
Package models is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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