You've already forked go-url-shortener
update assets use
This commit is contained in:
11
internal/templ/util/authorize.go
Normal file
11
internal/templ/util/authorize.go
Normal 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)
|
||||
}
|
||||
12
internal/templ/util/csrf.go
Normal file
12
internal/templ/util/csrf.go
Normal 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)
|
||||
}
|
||||
29
internal/templ/util/file.go
Normal file
29
internal/templ/util/file.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user