forked from rocboss/paopao-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move all api to v1 group and suport embed web ui to server
1. move all api to v1 group 2. web ui adapt all api to v1 group 3. support embed web ui to server if needed
- Loading branch information
Showing
11 changed files
with
138 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build !embed | ||
// +build !embed | ||
|
||
package routers | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// registerStatick stub function for register static asset route | ||
func registerStatick(e *gin.Engine) { | ||
// empty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//go:build embed | ||
// +build embed | ||
|
||
package routers | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/rocboss/paopao-ce/web" | ||
) | ||
|
||
// registerStatick register static assets route | ||
func registerStatick(e *gin.Engine) { | ||
routeStatic(e, "/", "/index.html", "/favicon.ico", "/assets/*filepath") | ||
} | ||
|
||
func routeStatic(e *gin.Engine, paths ...string) { | ||
staticHandler := http.FileServer(web.NewFileSystem()) | ||
handler := func(c *gin.Context) { | ||
staticHandler.ServeHTTP(c.Writer, c.Request) | ||
} | ||
for _, path := range paths { | ||
e.GET(path, handler) | ||
e.HEAD(path, handler) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ node_modules | |
dist | ||
dist-ssr | ||
*.local | ||
.env | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//go:build embed | ||
// +build embed | ||
|
||
package web | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
"net/http" | ||
) | ||
|
||
//go:embed dist/* | ||
var files embed.FS | ||
|
||
// NewFileSystem get an embed static assets http.FileSystem instance. | ||
func NewFileSystem() http.FileSystem { | ||
subfs, _ := fs.Sub(files, "dist") | ||
return http.FS(subfs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.