Documentation ¶
Index ¶
- Variables
- func CloseDB()
- func InitDB()
- func InitSession()
- func IsUserLogged(id interface{}) bool
- func Login(res http.ResponseWriter, req *http.Request)
- func Logout(res http.ResponseWriter, req *http.Request)
- func PlayersCreate(res http.ResponseWriter, req *http.Request)
- func PlayersCsv(res http.ResponseWriter, req *http.Request)
- func PlayersDelete(res http.ResponseWriter, req *http.Request)
- func PlayersNew(res http.ResponseWriter, req *http.Request)
- func PlayersRate(res http.ResponseWriter, req *http.Request)
- func PlayersRated(res http.ResponseWriter, req *http.Request)
- func PlayersShow(res http.ResponseWriter, req *http.Request)
- func PlayersUpdate(res http.ResponseWriter, req *http.Request)
- func RootCsv(res http.ResponseWriter, req *http.Request)
- func RootIndex(res http.ResponseWriter, req *http.Request)
- func UserLogged(req *http.Request, rm *mux.RouteMatch) bool
- func UsersCreate(res http.ResponseWriter, req *http.Request)
- type ExtPlayer
- type Options
- type Player
- type Rating
- type User
Constants ¶
This section is empty.
Variables ¶
var Db gorp.DbMap
Global instance that holds a connection to the DB. It gets initialized after calling the InitDB function. You have to call CloseDB in order to close the connection.
Functions ¶
func IsUserLogged ¶
func IsUserLogged(id interface{}) bool
Returns true if the user with the given id exists, false otherwise.
func Login ¶
func Login(res http.ResponseWriter, req *http.Request)
Login a user. It expects the "name" and "password" form values. Regardless if it was successful or not, it will redirect the user to the root path.
func PlayersCreate ¶
func PlayersCreate(res http.ResponseWriter, req *http.Request)
func PlayersCsv ¶
func PlayersCsv(res http.ResponseWriter, req *http.Request)
func PlayersDelete ¶
func PlayersDelete(res http.ResponseWriter, req *http.Request)
func PlayersNew ¶
func PlayersNew(res http.ResponseWriter, req *http.Request)
func PlayersRate ¶
func PlayersRate(res http.ResponseWriter, req *http.Request)
func PlayersRated ¶
func PlayersRated(res http.ResponseWriter, req *http.Request)
func PlayersShow ¶
func PlayersShow(res http.ResponseWriter, req *http.Request)
func PlayersUpdate ¶
func PlayersUpdate(res http.ResponseWriter, req *http.Request)
func RootIndex ¶
func RootIndex(res http.ResponseWriter, req *http.Request)
Renders the root page. It has three different options:
- If there's no user, it renders the "Create user" page.
- If the current user is not logged in, it render the "Login" page.
- If the current user is logged in, then it call homePage.
func UserLogged ¶
func UserLogged(req *http.Request, rm *mux.RouteMatch) bool
A route matcher as expected by the mux package. It returns true (thus, accepting the route) if the current user is logged in, false otherwise.
func UsersCreate ¶
func UsersCreate(res http.ResponseWriter, req *http.Request)
Creates a user. It expects the "name" and the "password" form values to be present. Moreover, only one user is allowed in this application.
Types ¶
type ExtPlayer ¶
type ExtPlayer struct { // The Id of the player (uuid). Id string // The name of the player. Name string // The minimum rating from the player. Min int // The maximum rating from the player. Max int // The average rating from the player. Avg string // All the ratings from this player. Ratings []Rating // The date of creation of this player. Created_at time.Time }
A Player with some useful data.
type Options ¶
type Options struct { // The id of the current user. Id string // The current player. One *ExtPlayer // All the players to be displayed. Players []*ExtPlayer // The maximum number of values to be displayed for a set of players. Values []int // The URL of "Download CSV". It might change depending where we are. Download string // Set to true if the current user is logged in. LoggedIn bool // Set to true if the views has to include Javascript. JS bool // Set to true if an error has happenned. Error bool }
This struct holds all the data that can be passed to a view.