Add admin routes

This commit is contained in:
2021-12-02 20:36:40 +00:00
parent 4011f3cace
commit 11d20eeb66
4 changed files with 46 additions and 9 deletions

31
http/admin.go Normal file
View File

@ -0,0 +1,31 @@
package http
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/pressly/goose/v3"
)
type AdminData struct {
}
func (h *Handler) admin(c *gin.Context) {
d := AdminData{}
c.HTML(http.StatusOK, "admin.html", d)
}
func (h *Handler) clearDatabase(c *gin.Context) {
d := AdminData{}
if err := goose.Down(h.Service.LegacyDB, "schema"); err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
}
if err := goose.Up(h.Service.LegacyDB, "schema"); err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
}
c.HTML(http.StatusOK, "admin.html", d)
}