Calorie counting web application written in the Go language

app.go 988B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package controllers
  2. import "github.com/revel/revel"
  3. type App struct {
  4. *revel.Controller
  5. }
  6. func (c App) Index() revel.Result {
  7. return c.Render()
  8. }
  9. func (c App) About() revel.Result {
  10. return c.Render()
  11. }
  12. func (c App) Me() revel.Result {
  13. return c.Render()
  14. }
  15. func (c App) Stats() revel.Result {
  16. return c.Render()
  17. }
  18. func (c App) Add(id int, product string, calories int) revel.Result {
  19. c.Validation.Required(id).Message("You must be logged on to add more calories.")
  20. c.Validation.Required(product).Message("You must include a product.")
  21. c.Validation.Required(calories).Message("You must provide the amount of calories")
  22. if c.Validation.HasErrors() {
  23. c.Validation.Keep()
  24. c.FlashParams()
  25. return c.Redirect(App.Index)
  26. }
  27. return c.Render()
  28. }
  29. func (c App) Goal() revel.Result {
  30. return c.Render()
  31. }
  32. func (c App) SetGoal() revel.Result {
  33. return c.Render()
  34. }
  35. func (c App) Streak() revel.Result {
  36. return c.Render()
  37. }