1
0
mirror of synced 2025-12-27 23:53:25 +00:00

fix(templates) correcting template directory

This commit is contained in:
itsmrval
2024-08-02 14:09:41 +02:00
parent 3b29312a2b
commit 6f20b84336

View File

@@ -2,8 +2,10 @@ package main
import (
"database/sql"
"embed"
"encoding/json"
"fmt"
"html/template"
"io/ioutil"
"log"
"net/http"
@@ -17,6 +19,8 @@ import (
"golang.org/x/oauth2/github"
)
var templatesFS embed.FS
type Link struct {
ID string
OriginalURL string
@@ -43,6 +47,8 @@ func initialize() (*App, error) {
oauthConfig := initGithubOAuth()
router := gin.Default()
tmpl := template.Must(template.ParseFS(templatesFS, "templates/*"))
router.SetHTMLTemplate(tmpl)
return &App{
DB: db,
@@ -80,7 +86,6 @@ func initGithubOAuth() *oauth2.Config {
}
func (app *App) SetupRoutes() {
app.Router.LoadHTMLGlob("templates/*")
app.Router.Static("/static", "./static")
app.Router.GET("/", app.homePage)
app.Router.POST("/", app.shortenURL)