Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
da97c8ec
authored
Oct 30, 2025
by
wzxjohn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(web): index page does not have analytic
parent
1ab86bc9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
common/embed-file-system.go
+12
-2
No files found.
common/embed-file-system.go
View file @
da97c8ec
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"embed"
"embed"
"io/fs"
"io/fs"
"net/http"
"net/http"
"os"
"github.com/gin-contrib/static"
"github.com/gin-contrib/static"
)
)
...
@@ -14,7 +15,7 @@ type embedFileSystem struct {
...
@@ -14,7 +15,7 @@ type embedFileSystem struct {
http
.
FileSystem
http
.
FileSystem
}
}
func
(
e
embedFileSystem
)
Exists
(
prefix
string
,
path
string
)
bool
{
func
(
e
*
embedFileSystem
)
Exists
(
prefix
string
,
path
string
)
bool
{
_
,
err
:=
e
.
Open
(
path
)
_
,
err
:=
e
.
Open
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
return
false
...
@@ -22,12 +23,21 @@ func (e embedFileSystem) Exists(prefix string, path string) bool {
...
@@ -22,12 +23,21 @@ func (e embedFileSystem) Exists(prefix string, path string) bool {
return
true
return
true
}
}
func
(
e
*
embedFileSystem
)
Open
(
name
string
)
(
http
.
File
,
error
)
{
if
name
==
"/"
{
// This will make sure the index page gose to NoRouter handler,
// which will use the replaced index bytes with analytic codes.
return
nil
,
os
.
ErrNotExist
}
return
e
.
FileSystem
.
Open
(
name
)
}
func
EmbedFolder
(
fsEmbed
embed
.
FS
,
targetPath
string
)
static
.
ServeFileSystem
{
func
EmbedFolder
(
fsEmbed
embed
.
FS
,
targetPath
string
)
static
.
ServeFileSystem
{
efs
,
err
:=
fs
.
Sub
(
fsEmbed
,
targetPath
)
efs
,
err
:=
fs
.
Sub
(
fsEmbed
,
targetPath
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
return
embedFileSystem
{
return
&
embedFileSystem
{
FileSystem
:
http
.
FS
(
efs
),
FileSystem
:
http
.
FS
(
efs
),
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment