You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.3KB

  1. package main
  2. import (
  3. "database/sql"
  4. "regexp"
  5. "github.com/gin-gonic/gin"
  6. )
  7. type GridLine struct {
  8. Id int `json:"id"`
  9. Name string `json:"name"`
  10. Points int `json:"points"`
  11. MaxPoints int `json:"maxPoints"`
  12. Presentations int `json:"presentations"`
  13. }
  14. type UserLine struct {
  15. Course string `json:"course"`
  16. Account string `json:"account"`
  17. Points int `json:"Points"`
  18. MaxPoints int `json:"maxPoints"`
  19. Min sql.NullFloat64 `json:"minimum"`
  20. MinType sql.NullString `json:"minimumType"`
  21. }
  22. type UserLineArr struct {
  23. Course string `json:"course"`
  24. AccPerc float64 `json:"actual"`
  25. Min float64 `json:"minimum"`
  26. MinType string `json:"minimumType"`
  27. }
  28. type percStruct struct {
  29. Type string `json:"type"`
  30. Minimum float64 `json:"minimum"`
  31. }
  32. type presStruct struct {
  33. Pres sql.NullInt64 `json:"presentations"`
  34. }
  35. type presSetStruct struct {
  36. Pres int `json:"presentations"`
  37. }
  38. func assertNil(x interface{}) {
  39. if x != nil {
  40. panic(x)
  41. }
  42. }
  43. func rewrite(engine *gin.Engine, match string, target string) gin.HandlerFunc {
  44. expr := regexp.MustCompile(match)
  45. return func(c *gin.Context) {
  46. if expr.MatchString(c.Request.URL.Path) {
  47. c.Request.URL.Path = target
  48. engine.ServeHTTP(c.Writer, c.Request)
  49. c.Abort()
  50. return
  51. } else {
  52. c.Next()
  53. }
  54. }
  55. }