user

package
v0.0.0-...-7f82438 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2015 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogOutSessionUser

func LogOutSessionUser(w http.ResponseWriter, r *http.Request, store *sessions.CookieStore) error

LogOutSessionUser logs out the user

func SetSessionUser

func SetSessionUser(w http.ResponseWriter, r *http.Request, username string, store *sessions.CookieStore) error

SetSessionUser sets the user in the session

Types

type ByRatingDesc

type ByRatingDesc []Interest

ByRatingDesc sorting type for Interests

func (ByRatingDesc) Len

func (a ByRatingDesc) Len() int

func (ByRatingDesc) Less

func (a ByRatingDesc) Less(i, j int) bool

func (ByRatingDesc) Swap

func (a ByRatingDesc) Swap(i, j int)

type FileRepo

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

FileRepo is a file based user repository

func (FileRepo) GetUser

func (r FileRepo) GetUser(name string) (*User, error)

GetUser gets a user per his username

func (FileRepo) GetUsers

func (r FileRepo) GetUsers() ([]User, error)

GetUsers is a function returning a list of users

func (FileRepo) SaveUser

func (r FileRepo) SaveUser(usr User) error

SaveUser is a function to persist user changes

type Interest

type Interest struct {
	Name     string
	Rating   float64
	Distance float64
}

Interest type

func NewInterest

func NewInterest(name string, rating float64) *Interest

NewInterest creates a new interest

type Interests

type Interests []Interest

Interests type

func (Interests) AsMap

func (ui Interests) AsMap() map[interface{}]float64

AsMap creates a map from the users interests

type Location

type Location struct {
	Longitude float64
	Latitude  float64
}

Location type

type MgoRepo

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

MgoRepo is a repository based on a MongoDb

func (MgoRepo) GetUser

func (r MgoRepo) GetUser(name string) (*User, error)

GetUser gets a user per his username

func (MgoRepo) GetUsers

func (r MgoRepo) GetUsers() ([]User, error)

GetUsers is a function returning a list of users

func (MgoRepo) SaveUser

func (r MgoRepo) SaveUser(usr User) error

SaveUser saves a user to the database

type Repository

type Repository interface {
	GetUsers() ([]User, error)
	GetUser(name string) (*User, error)
	SaveUser(user User) error
}

Repository type

func NewMgoRepo

func NewMgoRepo(url, database string) Repository

NewMgoRepo creates a new Mongo database repository

func NewRepo

func NewRepo(filepath string) (Repository, error)

NewRepo creates a new File base repository

type User

type User struct {
	ID        bson.ObjectId `bson:"_id,omitempty"`
	Name      string
	Location  Location
	Interests Interests
}

User type

func GetSessionUser

func GetSessionUser(w http.ResponseWriter, r *http.Request, repo Repository, store *sessions.CookieStore) (*User, error)

GetSessionUser gets the user stored in the session if there is one

func NewUser

func NewUser(name string, interests Interests) *User

NewUser creates a new user

Jump to

Keyboard shortcuts

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