-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move admin ui into embedded package, update ui routes to work with em…
…bedded content, update makefile
- Loading branch information
Showing
73 changed files
with
62 additions
and
2 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,53 @@ | ||
package frontend | ||
|
||
import ( | ||
"embed" | ||
"io" | ||
"io/fs" | ||
"net/http" | ||
) | ||
|
||
var ( | ||
//go:embed dist/assets/* | ||
adminResources embed.FS | ||
|
||
//go:embed dist/index.html dist/favicon.ico | ||
index embed.FS | ||
|
||
distFiles = must(fs.Sub(adminResources, "dist")) | ||
) | ||
|
||
func must(f fs.FS, err error) fs.FS { | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return f | ||
} | ||
|
||
func Index(w http.ResponseWriter, r *http.Request) { | ||
|
||
f, err := index.Open("dist/index.html") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
w.Header().Set("content-type", "text/html; charset=utf-8") | ||
io.Copy(w, f) | ||
} | ||
|
||
func Favicon(w http.ResponseWriter, r *http.Request) { | ||
|
||
f, err := index.Open("dist/favicon.ico") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
w.Header().Set("content-type", "image/x-icon") | ||
io.Copy(w, f) | ||
} | ||
|
||
func Assets(w http.ResponseWriter, r *http.Request) { | ||
|
||
http.StripPrefix("/", http.FileServer(http.FS(distFiles))).ServeHTTP(w, r) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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