Documentation
¶
Index ¶
- Variables
- func ParseURLDate(dateStr string) (err error, date time.Time)
- func SaveKilometers(dbmap *gorp.DbMap, date time.Time, fields []Field) (err error)
- func SaveTimes(dbmap *gorp.DbMap, date time.Time, fields []Field) (err error)
- type Config
- type Field
- type GetTimesInterface
- type Kilometers
- type Response
- type SaveInterface
- type Server
- type State
- type StateGetter
- type TimeRow
- type Times
Constants ¶
This section is empty.
Variables ¶
var ( // NotFound standard 404 not found NotFound = newResponse("^404 page not found\n$", 404) // Ok 200 ok Ok = newResponse("ok\n", 200) // UnknownField 400 an unknown field encountered in supplied data UnknownField = newResponse("invalid fieldname\n", 400) // NotParsable 400 could not parse request NotParsable = newResponse("could not parse request\n", 400) // InvalidDate coudl not parse the date provided InvalidDate = newResponse("invalid date\n", 400) // InvalidURL 400 invalid url, correct structure, but invalid InvalidURL = newResponse("invalid url", 400) // DbError error connecting to database DbError = newResponse("database eror", 500) )
Functions ¶
func ParseURLDate ¶
ParseURLDate parse a datestring used in the url to a time.Time object
func SaveKilometers ¶
SaveKilometers saves a the given Field array (wich is supplied by the user) if no data is saved for today it results in an insert, otherwise a update of the already saved data is done
Types ¶
type GetTimesInterface ¶
GetTimesInterface is the interface to swap out the GetTimes function when testing
type Kilometers ¶
type Kilometers struct { ID int64 `db:"Id"` Date time.Time Begin, Eerste, Laatste, Terug int Comment string }
Kilometers is the struct representing a db row in the kilometers table
func (*Kilometers) AddFields ¶
func (k *Kilometers) AddFields(fields []Field)
AddFields updates an existing Kilometers truct to update/insert into db with data posted by user
type Response ¶
Response a custum error response that gives some more ditails on the error
func CustomResponse ¶
CustomResponse takes a error and adds extra fields to convert it to a custom Response object
type SaveInterface ¶
SaveInterface is the interface to swap out the Save function when testing
type Server ¶
type Server struct { mux.Router Dbmap *gorp.DbMap StateFunc StateGetter SaveKilos SaveInterface SaveTimes SaveInterface GetTimes GetTimesInterface // contains filtered or unexported fields }
Server is the main type of this package it holds all the data required to run the app, the database connection, the webserver routes to handle, and the templates to parse
type StateGetter ¶
StateGetter is the interface to swap out the GetState function when testing
type TimeRow ¶
type TimeRow struct { ID int64 Date time.Time Begin, CheckIn, CheckOut, Laatste string Hours float64 }
TimeRow is a Times row converted to the format displayed in the frontend
func GetAllTimes ¶
GetAllTimes pulls all rows for a given month from the db and converts it all to TimeRow for displaying in the frontend