update assets use

This commit is contained in:
2024-12-11 17:37:58 +08:00
parent f6c961adb6
commit af08d9befc
25 changed files with 177 additions and 218 deletions

View File

@@ -0,0 +1,11 @@
package util
import (
"context"
"github.com/zhang2092/go-url-shortener/internal/middleware"
)
func GetAuthorize(ctx context.Context) *middleware.Authorize {
return middleware.GetUser(ctx)
}

View File

@@ -0,0 +1,12 @@
package util
import (
"html/template"
"net/http"
"github.com/gorilla/csrf"
)
func CsrfField(r *http.Request) template.HTML {
return csrf.TemplateField(r)
}

View File

@@ -0,0 +1,29 @@
package util
import "strings"
func GetCssFile(path ...string) []string {
var res []string
if len(path) > 0 {
for _, p := range path {
if strings.HasSuffix(p, ".css") {
res = append(res, p)
}
}
}
return res
}
func GetJsFile(path ...string) []string {
var res []string
if len(path) > 0 {
for _, p := range path {
if strings.HasSuffix(p, ".js") {
res = append(res, p)
}
}
}
return res
}