go 1.16 features

- use go embed instead of go-binary and remove all about old assets (go 1.16 feature)
- pin gox version (go 1.16 feature)
- update ci to go 1.16
This commit is contained in:
Nikita Kazarian
2021-03-05 03:38:08 +03:00
parent 68e6f2d117
commit 8e2c826ba3
12 changed files with 34 additions and 771 deletions

View File

@@ -3,6 +3,8 @@ package api
import (
"encoding/base64"
"fmt"
"github.com/sosedoff/pgweb/static"
"net/http"
neturl "net/url"
"regexp"
"strings"
@@ -56,13 +58,12 @@ func setClient(c *gin.Context, newClient *client.Client) error {
}
// GetHome renderes the home page
func GetHome(c *gin.Context) {
serveStaticAsset("/index.html", c)
func GetHome() http.Handler {
return http.FileServer(http.FS(static.Static))
}
// GetAsset renders the requested static asset
func GetAsset(c *gin.Context) {
serveStaticAsset(c.Params.ByName("path"), c)
func GetAssets() http.Handler {
return http.StripPrefix("/static/", http.FileServer(http.FS(static.Static)))
}
// GetSessions renders the number of active sessions