32 lines
590 B
Go
32 lines
590 B
Go
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)
|
|
}
|