Add clan-purge and player-purge. Optimized performance with template-init.
This commit is contained in:
48
main.go
48
main.go
@@ -6,11 +6,55 @@ import (
|
||||
"InfantrySkillCalculator/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/gorilla/sessions"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
var mainPageTemplates *template.Template
|
||||
var loginPageTemplates *template.Template
|
||||
var registerPageTemplates *template.Template
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
mainPageTemplates, err = template.ParseFiles(
|
||||
"./templates/index.html",
|
||||
"./templates/components/home_clan_bar.html",
|
||||
"./templates/components/opp_clan_bar.html",
|
||||
"./templates/components/home_player_list.html",
|
||||
"./templates/components/opp_player_list.html",
|
||||
"./templates/components/bottom_controls.html",
|
||||
"./templates/modals/delete_clan.html",
|
||||
"./templates/modals/add_clan.html",
|
||||
"./templates/modals/edit_clan.html",
|
||||
"./templates/modals/add_player.html",
|
||||
"./templates/modals/delete_player.html",
|
||||
"./templates/modals/edit_player.html",
|
||||
"./templates/modals/settings.html",
|
||||
"./templates/components/header.html",
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
loginPageTemplates, err = template.ParseFiles(
|
||||
"./templates/login.html",
|
||||
"./templates/components/header.html",
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
registerPageTemplates, err = template.ParseFiles(
|
||||
"./templates/register.html",
|
||||
"./templates/components/header.html",
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
//gin.SetMode(gin.ReleaseMode) // uncomment upon release
|
||||
|
||||
@@ -73,7 +117,9 @@ func main() {
|
||||
protected.GET("/settings", controllers.GetSettings)
|
||||
protected.PATCH("/settings", controllers.UpdateSettings)
|
||||
|
||||
admin.GET("/clear_cache", controllers.DeleteAllCaches)
|
||||
admin.DELETE("/clear_cache", controllers.DeleteAllCaches)
|
||||
admin.DELETE("/purge_players", controllers.DeleteAllPlayers)
|
||||
admin.DELETE("/purge_clans", controllers.DeleteAllClans)
|
||||
admin.POST("/create_code", controllers.CreateCode)
|
||||
|
||||
log.Println("Running on 8000...")
|
||||
|
||||
Reference in New Issue
Block a user