bisakhmondal commented on a change in pull request #1788:
URL: https://github.com/apache/apisix-dashboard/pull/1788#discussion_r633122753
##########
File path: api/internal/route.go
##########
@@ -91,3 +94,55 @@ func SetUpRouter() *gin.Engine {
return r
}
+
+type spaFileSystem struct {
+ http.FileSystem
+}
+
+func (fs *spaFileSystem) Open(name string) (http.File, error) {
+ f, err := fs.FileSystem.Open(name)
+ //Default failsafe page
+ if err != nil {
+ return fs.FileSystem.Open("index.html")
+ }
+ return f, err
+}
+
+var HTMLBlackListRoutes = []string{
+ "/apisix",
+ "/ping",
+}
+
+func serve(urlPrefix string, fss fs.FS) gin.HandlerFunc {
+ fileserver := http.FileServer(&spaFileSystem{http.FS(fss)})
+ if urlPrefix != "" {
+ fileserver = http.StripPrefix(urlPrefix, fileserver)
+ }
+ return func(c *gin.Context) {
+
+ if c.Request.Method == "GET" &&
+ (exists(urlPrefix, c.Request.URL.Path, &fss) ||
!isBlacklisted(c.Request.URL.Path)) {
Review comment:
the `exists` method and `isBlacklisted` are doing the same work in
different ways. Please let me know which one should be perfect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]